Forum Discussion
vishwajeet_hol - Using V2, you can use this to fetch the results and sort by views.
SELECT * FROM messages WHERE category.id IN ('CATEGORY_ID') AND is_solution = true ORDER BY metrics.views DESC LIMIT 6
Regarding the date range, V2 allows only to sort by message post time with depth 0, e.g.
SELECT subject, id FROM messages WHERE conversation.last_post_time > 2013-10-07T10:04:30-08:00
AND conversation.last_post_time < 2013-11-07T10:04:30-08:00 AND depth=0
ORDER BY conversation.last_post_time DESC
More info here. I hope this helps.
- vishwajeet_hol11 years agoExpert
Hi VarunGrazitti,
Thanks !!!
Now, I am able to fetch the results and sort by views using given query.
SELECT * FROM messages WHERE category.id IN ('CATEGORY_ID') AND is_solution = true ORDER BY metrics.views DESC LIMIT 6
To use date range, i tried this:
SELECT * FROM messages WHERE category.id IN ('CATEGORY_ID') AND conversation.last_post_time > 2015-03-16T10:04:30-08:00
AND conversation.last_post_time < 2015-07-16T10:04:30-08:00 AND depth=0 AND is_solution = true ORDER BY metrics.views DESC LIMIT 6But unable to get the required respose, because when we say is_solution = true then we can't satisfy the codition depth=0.
So how to use date range in above query.
Regards,
Vishwajeet.
- VarunGrazitti11 years agoBossNo, unless you find another way to filter it out, in API V2, you cannot use custom constraints, in this case the solution date.
See an idea here - https://community.lithium.com/t5/Product-Ideas/API-2-0-Be-able-to-use-custom-tags-as-a-constraint-for-messages/idc-p/189373#M8321
Another way could be (workaround) that in your code, you can skip the threads which have date > 30 days before today. I hope this helps.- vishwajeet_hol11 years agoExpert
VarunGrazitti Thanks for information !!!