-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data): Add usage_date to daily_usages (#2987)
## Description The goal of this PR is to add `usage_date` column to the `daily_usages` table. It will help fetching the correct usage for a specific date, without computing the `refreshed_at` values. Next PR will remove use of `refreshed_at` in favor of `usage_date`.
- Loading branch information
Showing
12 changed files
with
95 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddUsageDateToDailyUsages < ActiveRecord::Migration[7.1] | ||
def change | ||
safety_assured do | ||
add_column :daily_usages, :usage_date, :date | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20241219152909_add_index_on_usage_date_to_daily_usages.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddIndexOnUsageDateToDailyUsages < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
safety_assured do | ||
add_index :daily_usages, :usage_date, algorithm: :concurrently | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require "rails_helper" | ||
|
||
RSpec.describe Clock::ComputeAllDailyUsagesJob, type: :job do | ||
subject(:compute_job) { described_class } | ||
|
||
describe '.perform' do | ||
describe ".perform" do | ||
before { allow(DailyUsages::ComputeAllService).to receive(:call) } | ||
|
||
it 'removes all old webhooks' do | ||
compute_job.perform_now | ||
|
||
expect(DailyUsages::ComputeAllService).to have_received(:call) | ||
it "calls DailyUsages::ComputeAllService" do | ||
freeze_time do | ||
compute_job.perform_now | ||
expect(DailyUsages::ComputeAllService).to have_received(:call).with(timestamp: Time.current) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters