Forum Discussion

samudhraa's avatar
samudhraa
Expert
11 years ago

Count of Popular topics at Category level

Hi All ,


How can I get a count of popular topics at category level or Is it possible to get the number of messages in kudoed message leaderboard. I am trying to a custom component for popular topics in forum (most kudoed) using ,

kudos/messages/leaderboard

 

However I need to paginate this , for which I am using Lithium's in built pagination component which requires a total count of all the messages in leaderboard.

 

Thanks,

Sam

 

 

  • Hi Sam,

     

    Are you trying to get a count of messages that have kudos in a category, or are you trying to get a sum of all the kudos given in a category?

     

    If the former, you could probably do a search for messages in the category that have kudos, using the "has_kudos" filter. For example:

    /restapi/vc/search/messages/count?location=category%3ADeveloper&has_kudos=true&collapse_discussion=false

     This would give you count of all of the messages in the "Developer" category that have kudos. To get the actual messages, you could just remove the "/count" path parameter.

     

    If you're wanting a sum of all the kudos instead, you could probably do so using the metrics call for a category:

    http://lithosphere.lithium.com/t5/rest-api/bd-p/developers-rest-api?leaf-id=Category.metrics#Category.metrics

    You would just need to determine the name of the metric (you can find this in the admin) and the desired time range.

7 Replies

  • AdamN's avatar
    AdamN
    Khoros Oracle
    11 years ago

    Hi Sam,

     

    Are you trying to get a count of messages that have kudos in a category, or are you trying to get a sum of all the kudos given in a category?

     

    If the former, you could probably do a search for messages in the category that have kudos, using the "has_kudos" filter. For example:

    /restapi/vc/search/messages/count?location=category%3ADeveloper&has_kudos=true&collapse_discussion=false

     This would give you count of all of the messages in the "Developer" category that have kudos. To get the actual messages, you could just remove the "/count" path parameter.

     

    If you're wanting a sum of all the kudos instead, you could probably do so using the metrics call for a category:

    http://lithosphere.lithium.com/t5/rest-api/bd-p/developers-rest-api?leaf-id=Category.metrics#Category.metrics

    You would just need to determine the name of the metric (you can find this in the admin) and the desired time range.

  • samudhraa's avatar
    samudhraa
    Expert
    11 years ago

    Hi AdamN ,

     

    Thanks for your response. It gave me some direction to solve my issue.

     I am trying to get the former - the count of messages that have kudos in a cateogory. I tried the REST call you mentioned , but I got 0 values of count , and no messages.

    I tried to modify the REST call , by querying within the category , simply for messages , without the has_kudos parameter (/categories/id/categoryId/search/messages) . I even tried a global search.

    But I am still getting empty response , when I know for a fact there are 4 messages with kudoes. 

    May be I am missing something ?

     

    Thanks,

    Sam

     

  • samudhraa's avatar
    samudhraa
    Expert
    11 years ago

    Looks like I caught  myself. When I searched for a text ,using the q parameter , it returned an appropriate response. 

    ie., when I used something like this

    /categories/id/catId/search/messages?q=appit&has_kudos=true

     

    I got a list of messages.

    Now I would just have to figure out what to use as search parameter that would include all messages.

    Thanks again AdamN.

     

    Regards,

    Sam

  • AdamN's avatar
    AdamN
    Khoros Oracle
    11 years ago

    Depending on the size of your community, we may be able to enable empty searches, so that you don't have to specify a value for the q parameter. If that's something you're interested, please file a case so that our Support team can assist with the next steps.

     

    Otherwise, you can try to craft a query that will include all of the posts you're interested. For example:

    q=(is_root:true OR is_root:false)

    So this will include all root posts (original topic posts) as well as non-root posts (replies), which should in theory covery everything.

     

    You may have also noticed in my example, i included:

    collapse_discussion=false

    If you want to make sure you get all possible results, make sure you include that in your search query. Otherwise, results will be "collapsed", meaning results from the same thread will only have one entry in the results instead of separate entries for each message.

  • luk's avatar
    luk
    Boss
    10 years ago
    Wouldn't it be nice if there was a call like

    /categories/id/catId/messages/popular

    (as /popular call results are based on kudos)?

  • luk wrote:
    Wouldn't it be nice if there was a call like

    /categories/id/catId/messages/popular

    (as /popular call results are based on kudos)?

    +1 for this - the workaround doesn't seem to work without keywords supplied to search API endpoint. How do we get around that?