How do you sort recurring event

Lets say I want to show the next 6 events.

'Normally', I would sort on 'start' end check if 'it has ended before today'.

But if I have recurring events (lets say it goes on every friday for 5 weeks).

How should I sort / query for this?

(if you have suggestions on how to 'present them', please do (for example, if they are sorted on date, and one event started yesterday and will 'recur' in 6 days, should this list first (on start), or on 'next friday (which might not show it amongst the 6 events I have in the view)

1 Like

if you are using plone.app.event simply query the catalog as you would do for usual events.
the result set will only contain one entry for a recurring event.

on the brains then call plone.app.event.base.expand_events (i think this is the part you are missing)
typically you'll ask for EventAccessors and provide a start and enddate and sort on 'start'

count=0
result = []
for acc in expand_events(brains,
        RET_MODE_ACCESSORS,
        start=now,
        end=now + timedelta(EVENT_EXPAND_DAYS),
        sort='start',
        ):
    result.append(acc.url)
    count += 1
    if count == 6:
        break   

reading on EventAccessors and expand_events in https://ploneappevent.readthedocs.io/en/latest/development.html helped me a lot to understand the concept