Forum Discussion

tmarshall's avatar
tmarshall
Advisor
5 years ago

Message stats via APIv2

When viewing a message in our the community there are stats on that message that give context to the moderators to focus on those topics. We would like to bring those stats in via APIv2 and include Replies, Date of topic, views, Kudos, 'in conversation

I'm able to get a few of the data points but not all in my APIv2 query. 

 

https://community/api/2.0/search?q=SELECT id,replies.count(*),metrics.views,kudos.sum(weight),conversation.messages_count FROM messages where id = '1774748'

 

 

Question

The kudos.sum(weight) only brings back 3 rather than the total number of kudos. 

I'm not sure how to sum up the number of unique users in the topic? 

Appreciate the help on how to bring back the same stats in an APIv2 call. 

Thanks,

Tim

3 Replies

  • Hi tmarshall ,

     You can get the sum of kudos for a thread/topic using the following V2 API call

    SELECT kudos.sum(weight) FROM messages where topic.id = '***threadID**'

    Hope this may help your ask 🙂

    Give kudos if you find my posts helpful or mark as a solution if it answers your query.

    Thanks,
    Srujana Satya

  • tmarshall's avatar
    tmarshall
    Advisor
    5 years ago

    Hey satya Good to hear from you and hope you are doing well 😉 

    It seems when I do the query for kudos it is it is limited to that specific thread, but I'm trying to get the aggregate of the kudos for the topic. I managed to figure out that if I add 'topic.id' you can see all the kudos which mirror the same value found in the thread after adding up each one from each message to the initial topic. 

     

    https://community/api/2.0/search?q=SELECT sum(kudos.sum(weight)) FROM messages where topic.id = '1774748' LIMIT 1000

     

      The same is true for the author, and wil list out each author in the topic.

     

    https://community/api/2.0/search?q=SELECT author.login FROM messages where topic.id = '1774748' LIMIT 1000

     

     If I remove duplicates i can see the unique number of authors in the thread. 

    Do you how to make the  break out the code in the the following component? <component id="common.widget.discussion-stats"/> 

    In short we need to pass in the message.id and display the 'discussion-stats' but as JSON that another application can pick up. 

  • tmarshall's avatar
    tmarshall
    Advisor
    3 years ago

    There is one flaw recently discovered when using topic.id by our middleware found. If/when a moderator moves a post the query breaks. It was suggested to go back to using 'id', so made another post https://community.khoros.com/t5/Developer-Discussion/in-Conversation-LIQL-Query-from-Messages/m-p/706448 related to this topic as still need a clever way to get the #of conversation , or need to have the moderator update the link to the merged topic. This would probably be the best approach with the least amount of effort ðŸ˜‰