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

Duplicate events #2

Open
ghost opened this issue Dec 15, 2020 · 1 comment
Open

Duplicate events #2

ghost opened this issue Dec 15, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 15, 2020

The script generates duplicate events on start date for fetching Toggl entries. For each execution the script doesn't recognize the fact that on a previous execution it had already created an event starting a year ago. If I change start date (I set a week ago for example) I get the same bug and I have duplicate events a week ago.
At the moment I can't seem to understand why this happens, so I just wanted to let you know!

@RoguedBear
Copy link
Contributor

RoguedBear commented Dec 16, 2020

I had the same thing happening with me too. I suspect its because of GCal and Toggl sending different number of events for the same time. I have explained more of that stuff in my Pull request reply #1

So in my modification, I have set GCal to retrieve events 2 days prior to current time, and Toggl entries 1 day prior to current time. This has fixed the issue for me
Quote from my reply:

  • When getting all events from Toggl, instead of fetching it from last year, I've made it to fetch it from 1 day ago.
    1 day seems a reasonable time range to me instead of 1 year. less execution time, less headache 😅

  • Similarly for fetching GCal events, I've fetched events from 2 days ago instead of 1.

    • When fetching events from 1 day, the thing that happened was, for the same time range Toggl was sending all events from 12am of the previous day to the current time (say for example, 27 entries).
    • But, GCal was sending events within 24hr time range instead of events from 12am of the starting of the previous day (GCal sent, 21 events for the same time range)
      So to fix that, GCal now fetches events from 2 days prior to the current day, so now we have more GCal events than Toggl entries.
      This prevents duplicating of events which was happening with me when I made this change later on in the day.
      Your Logging code (Toggl entries length, GCal events length) helped me figure out why script was duplicating events in Calendar

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

No branches or pull requests

1 participant