Forum Discussion

Suchith's avatar
6 years ago

API call for Top Most viewed and Most Helpful

Hi, 

I want to retrieve Most viewed and Most Helpful data from the posts for that each category category and board level. 

Below V2 API will help to get most viewed message across all blogs.

SELECT * FROM messages where conversation.style='blog' ORDER BY metrics.views DESC limit 3

 Please let me know how can I restrict this for specific category or board to get Most Viewed and Most Helpful posts.

Thanks.

  • Suchith 
    You can put the board.id constraint in API like this

    select * from messages where board.id = 'BoardId' order by metrics.views DESC limit 3

    And I think helpfulness may relate to the popularity of the topic as I did not see anything else in message response which is closer to this

    select * from messages where board.id = 'BoardID' order by popularity DESC limit 3

     

  • Suchith 
    You can put the board.id constraint in API like this

    select * from messages where board.id = 'BoardId' order by metrics.views DESC limit 3

    And I think helpfulness may relate to the popularity of the topic as I did not see anything else in message response which is closer to this

    select * from messages where board.id = 'BoardID' order by popularity DESC limit 3

     

    • Suchith's avatar
      Suchith
      Ace

      VikasB 

      Thanks, what should be the constraint if we are planning to get top 3 view across community.


      • VikasB's avatar
        VikasB
        Boss

        For overall community, you can keep it defualt without any constraint. 

        For  community

        SELECT * FROM messages ORDER BY metrics.views DESC limit 3

        For Category 

        SELECT * FROM messages where category.id = 'CategoryId" ORDER BY metrics.views DESC limit 3

         For multiple boards

        SELECT * FROM messages where board.id in ('boardId1','boardId2') ORDER BY metrics.views DESC limit 3