Natkinson
4 years agoGenius
Can someone explain how to filter by last_publish_time
I am trying to write a custom component that involves filtering by last_publish_time (we're trying to grab posts from the past 7 days). But I'm having a difficult time understanding what number to us...
- 8 months ago
The docs for the last_publish_date constraint can be found here: https://developer.khoros.com/khoroscommunitydevdocs/docs/messages#last_publish_time-1
Basically you have to use a unix epoch timestamp in milliseconds which is inconsistent with other datetime constraints which require you to use an ISO-date (the same that is returned by the API if you query such a field...), for example post_time... it doesn't make any sense, but it is what it is...
The FreeMarker part would look something like this (untested):
<#assign now = datesupport.now /> <#assign lastWeek = now.addWeek(-1).millisecondsAsString /> <#assign query = "SELECT * FROM messages WHERE last_publish_time >= ${lastWeek} ORDER BY last_publish_time DESC LIMIT 10" /> <#assign response = liql(query) /> <#list (response.data.items)![] as obj> <#-- do your thing here with each message object --> </#list>
For more info about the custom Khoros datesupport FreeMarker context object see the docs here: https://developer.khoros.com/khoroscommunitydevdocs/reference/datesupport-1