-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Regional Records computation to Auxiliary table (#10122)
* Add helper method for temporary table swapping * Add Regional Records lookup table * Add regional records lookup to CAD computation * Use lookup table in CRR script * Add note about CRR depending on CAD runs * Specify what CAD actually does * Add sanitizer for new lookup table in dev dump * Add result ID to regional_records_lookup * Add common helper method for lookup table indexing * Update CRR warning box text * Don't run CRR on the read replica (now that we have lookup tables) * Add an option to recompute CRR index on form submit * Switch back aux computation order in final import step
- Loading branch information
Showing
11 changed files
with
158 additions
and
94 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
21 changes: 21 additions & 0 deletions
21
db/migrate/20241022093010_create_regional_records_lookup_table.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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateRegionalRecordsLookupTable < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table :regional_records_lookup do |t| | ||
t.references :Results, foreign_key: true, null: false, type: :int | ||
t.string "countryId", null: false | ||
t.string "eventId", null: false | ||
t.date "competitionEndDate", null: false | ||
t.integer "best", default: 0, null: false | ||
t.integer "average", default: 0, null: false | ||
|
||
t.index [:eventId, :countryId, :best, :competitionEndDate] | ||
t.index [:eventId, :countryId, :average, :competitionEndDate] | ||
end | ||
|
||
# Small hack because Rails doesn't support custom `t.references` names | ||
# but our Results tables have their own nomenclature | ||
rename_column :regional_records_lookup, :Results_id, :resultId | ||
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
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