File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ class SetupSmsReminderSriLanka2025JanJune < ActiveRecord ::Migration [ 6.1 ]
4+ PATIENTS_PER_DAY = 5000
5+ EXPERIMENTS_DATA = %w[ Jan Feb Mar Apr May Jun ] . map do |month |
6+ {
7+ start_time : "#{ month } 2025" . to_datetime . beginning_of_month ,
8+ end_time : "#{ month } 2025" . to_datetime . end_of_month ,
9+ current_patients_experiment_name : "Current Patient #{ month } 2025"
10+ }
11+ end
12+
13+ def up
14+ return unless CountryConfig . current_country? ( "Sri Lanka" ) && SimpleServer . env . production?
15+
16+ EXPERIMENTS_DATA . each do |experiment_data |
17+ ActiveRecord ::Base . transaction do
18+ Experimentation ::Experiment . current_patients . create! (
19+ name : experiment_data [ :current_patients_experiment_name ] ,
20+ start_time : experiment_data [ :start_time ] ,
21+ end_time : experiment_data [ :end_time ] ,
22+ max_patients_per_day : PATIENTS_PER_DAY
23+ ) . tap do |experiment |
24+ cascade = experiment . treatment_groups . create! ( description : "sms_reminders_cascade - #{ experiment_data [ :current_patients_experiment_name ] } " )
25+ cascade . reminder_templates . create! ( message : "notifications.sri_lanka.one_day_before_appointment" , remind_on_in_days : -1 )
26+ cascade . reminder_templates . create! ( message : "notifications.sri_lanka.three_days_missed_appointment" , remind_on_in_days : 3 )
27+ end
28+ end
29+ end
30+ end
31+
32+ def down
33+ EXPERIMENTS_DATA . map do |experiment_data |
34+ Experimentation ::Experiment . current_patients . find_by_name ( experiment_data [ :current_patients_experiment_name ] ) &.cancel
35+ end
36+ end
37+ end
Original file line number Diff line number Diff line change @@ -7857,6 +7857,7 @@ INSERT INTO "schema_migrations" (version) VALUES
78577857(' 20241125153335' ),
78587858(' 20241125155649' ),
78597859(' 20241126111757' ),
7860- (' 20241129212725' );
7860+ (' 20241129212725' ),
7861+ (' 20241204155510' );
78617862
78627863
You can’t perform that action at this time.
0 commit comments