Add some naive filtering to the Toggl scraping job to ignore time entries that have already been tracked

This commit is contained in:
Joshua Coles 2023-10-06 22:06:54 +01:00
parent 0cb03812cf
commit 84143c683f

View File

@ -31,6 +31,9 @@ class ScrapeTogglJob < ApplicationJob
entries_data.each do |entry|
entry_title = entry['description']
# Skip if we've already seen this entry, NOTE: we assume that there is only one inner_entry per time entry
next if TrackedTimeEntry.exists?(associated_toggl_entry_id: entry['time_entries'][0]['id'])
if (lecture = lectures.find_by(title: entry_title))
is_concurrent = entry['time_entries'].any? do |inner_entry|
(Time.new(inner_entry['start']) - lecture.start_time).abs < 10.minutes