Forum Discussion

Kilfaxi's avatar
Kilfaxi
Contributor
7 years ago

Sum kudos for all messages in a specific board using Community API V2

I imagine there must be a way to do this.

The query that I want to get to work would look as follows:

SELECT message.id, user.email, kudos.sum(weight)
FROM messages
WHERE board.id = 'ABC'

And what I expect back would be the topic message ID, email address of the user that created the topic message and the total kudos for the topic message.

This query works for me without kudos.sum(weight), but with it I receive an error that my query is invalid.

 

The documentation for the message collection, below, clearly contains examples that show kudos.sum(weight) should work.

https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=messages

 

Specifically, from the "Functions" section:

SELECT kudos.sum(weight) FROM messages

What am I doing wrong here?

  •  

    The query below worked.

    It appears that user.email is invalid (author.email instead), and message.id is also invalid (id instead).

    Finally, adding depth = 0 just makes the results set a bit cleaner.

     

    SELECT author.email, id, kudos.sum(weight) FROM messages WHERE board.id='ABC' AND depth = 0

     

    Im still not understanding why there is a user object referenced within messages, but you cannot do user.email, etc.

     

  •  

    The query below worked.

    It appears that user.email is invalid (author.email instead), and message.id is also invalid (id instead).

    Finally, adding depth = 0 just makes the results set a bit cleaner.

     

    SELECT author.email, id, kudos.sum(weight) FROM messages WHERE board.id='ABC' AND depth = 0

     

    Im still not understanding why there is a user object referenced within messages, but you cannot do user.email, etc.