From 39554fb176644725d00664db71f51755e6baf472 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sun, 4 Feb 2024 19:43:43 +0000 Subject: [PATCH] Update date parameters and simplify broadcast call --- app/jobs/scrape_toggl_job.rb | 8 ++++---- app/lib/toggl.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/jobs/scrape_toggl_job.rb b/app/jobs/scrape_toggl_job.rb index a70618e..5f54b0d 100644 --- a/app/jobs/scrape_toggl_job.rb +++ b/app/jobs/scrape_toggl_job.rb @@ -20,8 +20,8 @@ class ScrapeTogglJob < ApplicationJob toggl_project_id, # TODO: Work out better limits - start_time: Time.new('2023-01-01'), - end_time: Time.new('2024-01-01') + start_time: course.semester_start_date - 2.months, + end_time: course.semester_start_date + 15.weeks + 2.months, ) puts("Entries data for #{course.title}: #{entries_data}") @@ -88,7 +88,7 @@ class ScrapeTogglJob < ApplicationJob associated_toggl_entry_id: entry['time_entries'][0]['id'], ) - broadcast_update_to lecture, :status + lecture.broadcast_update elsif (lecture_title_match = entry_title.match(review_regex)) and (lecture = lectures.find_by(title: lecture_title_match[1])) lecture.tracked_time_entries.create!( kind: :review, @@ -96,7 +96,7 @@ class ScrapeTogglJob < ApplicationJob associated_toggl_entry_id: entry['time_entries'][0]['id'], ) - broadcast_update_to lecture, :status + lecture.broadcast_update end end end diff --git a/app/lib/toggl.rb b/app/lib/toggl.rb index aa0b812..0836fa6 100644 --- a/app/lib/toggl.rb +++ b/app/lib/toggl.rb @@ -17,8 +17,8 @@ module Toggl "#{TOGGL_PORTAL_URL}/report", body: { # TODO: Replace these, rails keeps complaining about deprecations - "start_date": start_time.to_date.to_fs(), - "end_date": end_time.to_date.to_fs(), + "start_date": start_time.to_date.to_fs(:db), + "end_date": end_time.to_date.to_fs(:db), "project_ids": [toggl_project_id] }.to_json, headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }