Update date parameters and simplify broadcast call

This commit is contained in:
Joshua Coles 2024-02-04 19:43:43 +00:00
parent af3f2ca39d
commit 39554fb176
2 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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' }