Skip to content

Commit 8e22d10

Browse files
author
Alistair Davidson
committed
linter-compliant version using Time.zone.parse after the .load_rails call
1 parent 45135dc commit 8e22d10

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/lib/mavis_cli/reporting_api/update_vaccination_events.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33
module MavisCLI
44
module ReportingAPI
55
class UpdateVaccinationEvents < Dry::CLI::Command
6-
desc "Update ReportingAPI Vaccination Events"
6+
desc <<-DESC
7+
8+
Update ReportingAPI Vaccination Events for all VaccinationRecords created after a given DateTime.
9+
DateTimes can be given in any format parsable by Time.parse.
10+
Defaults to one year ago.
11+
DESC
12+
713
option :from,
8-
desc:
9-
"Only consider vaccination records created after this time (any format parsable by Time.parse())",
14+
desc: "Only consider vaccination records created after this time",
1015
type: :string,
1116
optional: true,
12-
aliases: %w[-f --from],
13-
default: (Time.zone.now - 365).iso8601
17+
aliases: %w[--from],
18+
default: nil
1419

15-
def call(from:, **)
20+
def call(from: nil, **)
1621
MavisCLI.load_rails
1722

18-
min_datetime = Time.zone.parse(from)
23+
min_datetime = from ? Time.zone.parse(from) : (Time.zone.now - 1.year)
1924

2025
records = VaccinationRecord.where("created_at > ?", min_datetime)
2126
puts "#{records.count} VaccinationRecords created since #{min_datetime.iso8601}"

0 commit comments

Comments
 (0)