Forum Discussion
6 Replies
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 DESCMore info here. I hope this helps.
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.
- No, 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. VarunGrazitti Thanks for information !!!
Hi VarunGrazitti,
Used below code given by you :
SELECT * FROM messages WHERE category.id IN ('CATEGORY_ID') AND is_solution = true ORDER BY metrics.views DESC LIMIT 6
It gives six solutions in that category ordered by no. of views.
Suppose, I want only one solution per topic.
That meance if a post has multiple solutions,I want only a single latest solution.
I think we have to use Distinct topic.id for this.
Any idea about how to implement it.
Thank you.
Regards,
Vishwajeet
- irach158 years agoMaven
Hi VarunGrazitti,
2 years ago ;-), was you able to implement it?
I need something similar, latest 5-7 solutions fro a specific board, sorted by acceptance date.
And show subject, some body content and acceptance date.
Any code samples appreciated.
Related Content
- 10 months ago
- 2 years ago
- 3 years ago
- 10 months ago
- 3 years ago