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

SyncDelay #372

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

SyncDelay #372

wants to merge 3 commits into from

Conversation

Lonestarjeepin
Copy link
Collaborator

@Lonestarjeepin Lonestarjeepin commented Sep 29, 2023

SyncDelay processes each source Calendar individually instead of grouping them together by Target Calendar before processing. By handling each calendar individually, I was able to define a SyncDelay on a per-calendar basis. The default is whatever the script trigger (howFrequent) is set to, but the SyncDelay can be set to skip syncing on a given run if the SyncDelay hasn't "expired". For example: if howFrequent is 15, but SyncDelay on a given calendar is 60, then that calendar will only sync once every 4th iteration of the script (aka once per hour). However, another calendar in the same script could still sync every 15 minutes.

For the developers: I had to modify the fromGAS entries (5 in total) to use the sourceCalendarName instead of "true" to avoid conflicts with multiple sources writing to the same target calendar (but not at the same time). However, the first time you run this new code, that change itself will cause duplication of all events that currently existed because they were from fromGAS=true. I didn't include it here, but a possible solution would be to put in a step that checks for fromGAS=true and removes all of those events.

SyncDelay processes each source Calendar individually instead of grouping them together by Target Calendar before processing.  By handling each calendar individually, I was able to denote a Sync Delay on a per-calendar basis.  The default is whatever the script trigger (howFrequent) is set too, but the Sync Delay can be set to skip syncing on a given run if the Sync Delay hasn't "expired".
@Lonestarjeepin
Copy link
Collaborator Author

I'm running into version-control issues so this pull actually has the code from #358 as well as #217 . I'm sure this probably isn't the right way to do it... sorry!

@derekantrican
Copy link
Owner

I'd really like to avoid adding additional properties to the calendars arrays until they're redesigned (see #311). However, if this is critically needed for some reason, feel free to say so and we can discuss it further

@Lonestarjeepin
Copy link
Collaborator Author

I wouldn't say the feature itself is critical (defining multiple sync schedules) although it was requested in #346 which gave me a use-case to implement this change. My main impetus in redesigning the script this way was to enable a lot of other feature-requests I've seen that (to me) would need to be executed at the individual source-calendar-level rather than the target-calendar-level. The Sync Delay feature is just a Trojan Horse for the real change in how the code executes. I agree that defining more and more parameters on the individual source calendars could be messy in the current configuration of the script and totally agree with your direction in #311. I was just hoping this might open some doors to accomplish other feature requests... and I got stuck on the idea so I couldn't stop until I figured it out!!!

@jonas0b1011001
Copy link
Collaborator

For the developers: I had to modify the fromGAS entries (5 in total) to use the sourceCalendarName instead of "true" to avoid conflicts with multiple sources writing to the same target calendar

By using fromGAS=${ScriptApp.getScriptId()} we would allow users to set up multiple independant copies (with different sync intervals) of the script working on the same target calendar.

@Lonestarjeepin
Copy link
Collaborator Author

Lonestarjeepin commented Oct 11, 2023 via email

@jonas0b1011001
Copy link
Collaborator

I totally get that.
My suggestion was more like a possible easy to do workaround for different sync intervals..until we get #311 and possibly a quite substantial code overhaul done.

@Lonestarjeepin
Copy link
Collaborator Author

Lonestarjeepin commented Oct 11, 2023 via email

@jonas0b1011001
Copy link
Collaborator

#311 is about replacing the sourceCalendars array with a js object. Creating a html UI is not neccessarily needed for that, however i don't want to stop you from giving it a go ;P

@Lonestarjeepin
Copy link
Collaborator Author

Lonestarjeepin commented Oct 11, 2023 via email

@jonas0b1011001
Copy link
Collaborator

Updating this PR to include changes made in v5.8 of master.
Updating PR for changes made in v5.8 release.
@Lonestarjeepin Lonestarjeepin mentioned this pull request Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Add feature to allow each target calendar to have a different sync refresh
3 participants