We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 6960096 + 7555981 commit 9c6e108Copy full SHA for 9c6e108
1 file changed
lib/tasks/data_migration.rake
@@ -5,4 +5,22 @@ namespace :data_migration do
5
task delete_clinic_session_notifications: :environment do
6
SessionNotification.where(type: [1, 2]).delete_all
7
end
8
+
9
+ desc "Delete sessions that have not been scheduled."
10
+ task delete_unscheduled_sessions: :environment do
11
+ destroyed_sessions =
12
+ Session
13
+ .where(dates: [])
14
+ .find_each
15
+ .filter_map do |session|
16
+ next if session.consent_notifications.exists?
17
+ next if session.session_notifications.exists?
18
+ next if session.vaccination_records.exists?
19
+ next if ConsentForm.where(original_session: session).exists?
20
21
+ session.tap(&:destroy!)
22
+ end
23
24
+ puts "Deleted #{destroyed_sessions.count} sessions"
25
26
0 commit comments