Forum Discussion

ronaksomani's avatar
10 years ago

How to show highest Kudos posts using API2?

Hi,

I want to show most active posts based on either number of kudos or views. I found a way to implement based on number of replies. But could not find similar approach for kudos/views. 

For replies : SELECT * FROM messages Where depth=0 ORDER BY replies.count(*) DESC

 

I need approach using API2 (LiQl). Can any one help?

  • ronaksomani - You can do it either way,

     

    Based on the number of Kudos:

    SELECT * FROM messages WHERE kudos.sum(weight)>0 AND depth = 0 ORDER BY kudos.sum(weight) DESC Based on the number of views:
    SELECT * FROM messages WHERE depth = 0 ORDER BY metrics.views DESC

     

  • ronaksomani - You can do it either way,

     

    Based on the number of Kudos:

    SELECT * FROM messages WHERE kudos.sum(weight)>0 AND depth = 0 ORDER BY kudos.sum(weight) DESC Based on the number of views:
    SELECT * FROM messages WHERE depth = 0 ORDER BY metrics.views DESC

     

    • ronaksomani's avatar
      ronaksomani
      Mentor

      VarunGrazitti Thank you for the response.

      Is there any way I can retrieve most active post based on combination of (replies / kudos / views)?

      • VarunGrazitti's avatar
        VarunGrazitti
        Boss

        ronaksomani  - Yes, you can do that, you can sort them based upon any one factor, either views, kudos or replies. In the following query, I've sorted it by views and included the kudos and replies as well.

         

        SELECT * FROM messages WHERE kudos.sum(weight)>0 AND replies.count(*) > 0 AND depth = 0 ORDER BY metrics.views DESC

         

        I hope this helps.