Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: bundler
directories:
- "/"
- "/gemfiles"
schedule:
interval: weekly
open-pull-requests-limit: 5
labels:
- dependencies
- ruby
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 5
labels:
- DevOps
- dependencies
- github_actions
26 changes: 14 additions & 12 deletions spec/dfe/analytics/services/entity_table_checks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
end

it 'uses created_at if it exists and has no null values' do
Candidate.create!(id: 1, email_address: 'first@example.com')
Candidate.create!(id: 2, email_address: 'second@example.com')
Candidate.create!(id: 1, email_address: 'first@example.com', created_at: 2.days.ago, updated_at: 2.days.ago)
Candidate.create!(id: 2, email_address: 'second@example.com', created_at: 1.day.ago, updated_at: 1.day.ago)

table_ids = Candidate.order(:created_at).pluck(:id)
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
checksum = Digest::MD5.hexdigest(table_ids.join)

described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
Expand Down Expand Up @@ -139,14 +139,16 @@
end

it 'defaults to created_at when updated_at is null but created_at exists' do
Candidate.create!(id: 1, email_address: 'first@example.com', updated_at: nil, created_at: 2.hours.ago)
Candidate.create!(id: 2, email_address: 'second@example.com', updated_at: nil, created_at: 1.hour.ago)
Candidate.create!(id: 3, email_address: 'third@example.com', updated_at: nil, created_at: 3.hours.ago)
cutoff = Time.zone.parse(checksum_calculated_at)

Candidate.create!(id: 1, email_address: 'first@example.com', updated_at: nil, created_at: cutoff - 3.hours)
Candidate.create!(id: 2, email_address: 'second@example.com', updated_at: nil, created_at: cutoff - 2.hours)
Candidate.create!(id: 3, email_address: 'third@example.com', updated_at: nil, created_at: cutoff - 1.hour)

# Ensure updated_at is not nil
Candidate.update_all(updated_at: Time.now)
Candidate.update_all(updated_at: cutoff - 30.minutes)

table_ids = Candidate.order(:created_at).pluck(:id)
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
checksum = Digest::MD5.hexdigest(table_ids.join)

described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
Expand All @@ -166,7 +168,7 @@
order_column = 'CREATED_AT'
[123, 124, 125].map { |id| Application.create(id: id) }
application_entities = DfE::Analytics.entities_for_analytics.select { |entity| entity.to_s.include?('application') }
table_ids = Application.where('created_at < ?', checksum_calculated_at).order(created_at: :asc).pluck(:id)
table_ids = Application.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
checksum = Digest::MD5.hexdigest(table_ids.join)

application_entities.each do |application|
Expand All @@ -186,7 +188,7 @@
it 'sends an entity table check event' do
[130, 131, 132].map { |id| Candidate.create(id: id) }
candidate_entities = DfE::Analytics.entities_for_analytics.select { |entity| entity.to_s.include?('candidate') }
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(created_at: :asc).pluck(:id)
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
checksum = Digest::MD5.hexdigest(table_ids.join)

candidate_entities.each do |candidate|
Expand All @@ -211,7 +213,7 @@

Candidate.update_all(created_at: DateTime.parse(checksum_calculated_at) - 1.hour)

table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:updated_at).pluck(:id)
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
checksum = Digest::MD5.hexdigest(table_ids.join)

described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
Expand All @@ -228,7 +230,7 @@
end

it 'returns zero rows and checksum if table is empty' do
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(created_at: :asc).pluck(:id)
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
checksum = Digest::MD5.hexdigest(table_ids.join)
described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)

Expand Down
Loading