Forum Discussion

Lindsey's avatar
Lindsey
Leader
5 years ago

API query equivalent to "trending discussions"

We want our trending discussions component to be formatted completely differently than the OOTB component, so we tried creating a custom component for that.  What is an equivalent REST query that ...
  • Payal's avatar
    5 years ago

    Lindsey  - I think OOTB Trending Discussions have following criteria:

    Messages created in the past 7 or 30 days (which you have configured in admin panel) that have received the most kudos.

    So, you can use the following V2 Query to get trending messages of last 7 days:

    <#assign now = datesupport.now />
    <#assign today = now.millisecondsAsString?number?number_to_datetime?iso("Europe/Zurich") />
    <#assign lastWeek = now.addWeek(-1).millisecondsAsString?number?number_to_datetime?iso("Europe/Zurich") />
    <#assign query = "SELECT * FROM messages WHERE post_time > " + lastWeek + " AND post_time < " + today + " and kudos.sum(weight) > 0 ORDER BY kudos.sum(weight) DESC" />

     

    Please let me know if this helps.

    Thanks!