Skip to content

Commit 34fe3ff

Browse files
authored
Setup SMS for Sri Lanka H1'25 (#5504)
**Story card:** [sc-14154] ## Because The current SMS notifications for SL expires this month. We need to setup more notifications through H1 next year. ## This addresses Setting up SMS notifications for SL ## Test instructions n/a
1 parent 57012ad commit 34fe3ff

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

db/structure.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)