Forum Discussion

mfeltscher's avatar
11 years ago

Get polls ordered by their start_date

Hi there

 

I'm trying to get the active poll with the most recent start date. Therefore I'm looking for a ReST API call to get polls ordered by their start date. Is this possible somehow?

How are the polls ordered by default if i call /restapi/vc/polls/active ?

 

Thanks,

Moreno

  • I don't know about polls specifically, but you can't normally order REST query results. However, you can sort the results in FreeMarker, so you can create a custom endpoint to achieve this.

     

    For example, I've used this technique to get a list of all products ordered by average rating.

     

    The FreeMarker reference for sorting sequences is here:

    http://freemarker.org/docs/ref_builtins_sequence.html#ref_builtin_sort

     

2 Replies

  • I don't know about polls specifically, but you can't normally order REST query results. However, you can sort the results in FreeMarker, so you can create a custom endpoint to achieve this.

     

    For example, I've used this technique to get a list of all products ordered by average rating.

     

    The FreeMarker reference for sorting sequences is here:

    http://freemarker.org/docs/ref_builtins_sequence.html#ref_builtin_sort

     

  • mfeltscher's avatar
    mfeltscher
    Expert
    11 years ago

    Hi nathan 

     

    Thank you for your response.

     

    This is what I thought.. I will do it manually then.

     

    We have exactely the same issue for the products as well, but a costum endpoint wouldn't solve this since we have to manage around 200k products which would take forever to sort.

     

    Thanks

    Moreno