Skip to content

Commit

Permalink
Download data from all supported agencies every night
Browse files Browse the repository at this point in the history
See #75.
  • Loading branch information
tdooner committed Oct 14, 2022
1 parent 1394b0a commit 624240f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/lib/disclosure_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def initialize(agency = NetfileAgency.coak)
end

def download
latest = Filing.order(filed_at: :desc).first
latest = Filing.where(netfile_agency: @agency).order(filed_at: :desc).first
puts '==================================================================='
puts 'Beginning State:'
puts "Beginning State for Netfile agency #{@agency.shortcut}:"
puts
puts "Filings: #{Filing.count}"
puts "Filings: #{Filing.where(netfile_agency: @agency).count}"
puts "Latest: #{latest&.filed_at}"
puts '==================================================================='

Expand Down Expand Up @@ -47,11 +47,11 @@ def download
end
end

latest = Filing.order(filed_at: :desc).first
latest = Filing.where(netfile_agency: @agency).order(filed_at: :desc).first
puts '==================================================================='
puts 'Ending State:'
puts
puts "Filings: #{Filing.count}"
puts "Filings: #{Filing.where(netfile_agency: @agency).count}"
puts "Latest: #{latest&.filed_at}"
puts '==================================================================='
end
Expand Down
8 changes: 6 additions & 2 deletions lib/tasks/disclosure_alert.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ namespace :disclosure_alert do

desc 'Download latest records'
task download: :environment do
DisclosureDownloader.new.download
NetfileAgency.each_supported_agency do |agency|
DisclosureDownloader.new(agency).download
end
end

desc 'Download latest records and send email'
task download_and_email_daily: :with_configuration do
today = TZInfo::Timezone.get('America/Los_Angeles').now.to_date
DisclosureDownloader.new.download
NetfileAgency.each_supported_agency do |agency|
DisclosureDownloader.new(agency).download
end
DisclosureEmailer.new(today - 1).send_email
end

Expand Down

0 comments on commit 624240f

Please sign in to comment.