Forum Discussion

hroppanen's avatar
8 years ago

Get most viewed messages in last two weeks from a board

Is there a way to get messages ordered by most viewed in a specific time period? I would like to get most viewed messages in the last two weeks from a board. I am using API v2.

 

edit: To be clear I want to limit message view count to a certain time period.

  • hroppanen,

     

    We had a similar requirement in two of our communities. We were able to achieve this by using bulk data API. However, you need to store this data in order to generate these type of metrics (and much more!). This is a time-taking solution but worth trying if there are many other metrics you would like to see for your community that Lithium does not provide using the normal API calls.

    Here is the documentation link around Bulk data API.

     

    Hope this helps!

     

9 Replies

  • satya's avatar
    satya
    Expert
    8 years ago

    Hi hroppanen,

     

    You can try this 

    SELECT subject, id,metrics.views FROM messages WHERE post_time > 2017-01-01T10:04:30-08:00 AND post_time < 2017-08-01T10:04:30-08:00 ORDER BY metrics.views DESC

    You can give the required date in the date section. Check out this link for more info

     

     

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

    Thanks,
    Srujana Satya

  • hroppanen's avatar
    hroppanen
    Ace
    8 years ago

    TariqHussain This seems to be an invalid query. I guess you can't have

    and post_time > 2017-08-01T00:00:00+00:00

    after

    order by metrics.views DESC

     

  • satya TariqHussain Sorry, but this will give me messages that are posted between a certain time period and those are then ordered by views.  It is not what I am looking for.

  • hroppanen,

     

    We had a similar requirement in two of our communities. We were able to achieve this by using bulk data API. However, you need to store this data in order to generate these type of metrics (and much more!). This is a time-taking solution but worth trying if there are many other metrics you would like to see for your community that Lithium does not provide using the normal API calls.

    Here is the documentation link around Bulk data API.

     

    Hope this helps!

     

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    8 years ago

    Hi hroppanen

    there isn't a way that I am aware of to select a subset of a certain metric based on a time period. I think srujanayeruvaka's suggestion is the recommended approach.

    Thanks,

  • Thanks for all the comments and specially srujanayeruvaka for the solution! Bulk API way might be too much for this things but anyway it is good to know. Cheers!