Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add possibility to have a eventsShowAmount #206

Closed
machfr opened this issue Feb 27, 2019 · 5 comments
Closed

Feature: Add possibility to have a eventsShowAmount #206

machfr opened this issue Feb 27, 2019 · 5 comments
Labels

Comments

@machfr
Copy link

machfr commented Feb 27, 2019

Hello,

You have the possibility to collect iCal events by using one of the following: eventsFromInterval, eventsFromRange or sortEventsWithOrder.

It would be a good feature to have so it is possible to use: nextEventsFromDate with the options of setting a start date and how many events to collect.

sortEventsWithOrder('2019-02-27', 20)

It would then start from 27th of February and give us back the next 20 events in the list.

or even better yes have a option where you also set defaultTimezone and such called maxEvents which default is 0 and then it takes unlimited and if you set it to 20 it only give us 20 events.

Hope this is a feature you will add.

@u01jmg3 u01jmg3 self-assigned this Mar 2, 2019
@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 5, 2019

Happy to accept a PR.

Have you tried the functionality PR #190 added? Although it doesn't allow you to specify exactly 20 events (because without expanding a recurrence rule this might be unknown), it does allow you to define a rough window to evaluate the events of.

@machfr
Copy link
Author

machfr commented Mar 6, 2019

As I understand it, that is not quit what we need.
The reason is that we need lets say next 25 events.. but they can happen over 3 days or it can happen over multiple years as we don't know which calendars people insert. so to limit it so we don't grab everything that happens over xx time this would be a neat solution to force to only a set amount of events :)

Also if I misunderstood what #190 does I am sorry :)

@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 6, 2019

It isn't as simple as requesting upfront the first 25 events. The chances are your iCal feed will contain events using RRULE (a recurrence event). Until you evaluate this rule you won't know how many events it contains in order to apply a limit. Similarly, if you want to sort the events in date order, until you have evaluated each recurrence rule within your feed you can't apply an ordering.

This is why I believe @marcelstoer chose the $filterDaysBefore and $filterDaysAfter approach.

Could you use the functionality in #190 and increase $filterDaysAfter (say 7 days at a time) until you get the desired number of events?

I realise that the first 25 events for one person could occur in the first 3 days of their feed but for another person this might be over multiple years.

@marcelstoer
Copy link
Contributor

marcelstoer commented Mar 6, 2019

@machfr as I was dragged into the discussion I'll give you my $.02.

nextEventsFromDate with the options of setting a start date and how many events to collect.

You can certainly do that BUT just like eventsFromInterval, eventsFromRange et.al. this requires that the entire calendar is parsed, and thus loaded into memory, first. That's the point that @u01jmg3 was trying to make AFAIU.

For my project I was parsing corporate meeting room calendars. As you can imagine such calendars tend to get huge when exploded i.e. with all their recurrence rules evaluated. Remember, a single event that occurs daily will generate a new event instance for every day when this parser processes the calendar.

#190 added the option to drop all events outside a given range very early in the parse process at the cost of some precision (timezone calculations not done at that point). This massively reduces the total time for parsing a calendar. Same goes for memory consumption of course. Precondition is that you know upfront that you don't care about events outside that range. In my case I was only interested in events from yesterday, today and tomorrow. So, I set the fuzzy parse range to +-3d and then use eventsFromRange with +-1d.

@machfr
Copy link
Author

machfr commented Mar 7, 2019

Yea that makes sense, didn't think about the recurring rules and all that, I will try and use the stuff you suggested :)

And also thank you both of you for taking the time to explain it to me.

@u01jmg3 u01jmg3 removed their assignment Mar 12, 2019
@u01jmg3 u01jmg3 closed this as completed Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants