Skip to content

SyncDelay#372

Open
Lonestarjeepin wants to merge 3 commits into
masterfrom
Sync-Delay
Open

SyncDelay#372
Lonestarjeepin wants to merge 3 commits into
masterfrom
Sync-Delay

Conversation

@Lonestarjeepin

@Lonestarjeepin Lonestarjeepin commented Sep 29, 2023

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Lonestarjeepin commented Oct 11, 2023 via email

Copy link
Copy Markdown
Collaborator Author

@jonas0b1011001

Copy link
Copy Markdown
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

Lonestarjeepin commented Oct 11, 2023 via email

Copy link
Copy Markdown
Collaborator Author

@jonas0b1011001

Copy link
Copy Markdown
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

Lonestarjeepin commented Oct 11, 2023 via email

Copy link
Copy Markdown
Collaborator Author

@jonas0b1011001

Copy link
Copy Markdown
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