From 44dffbc42833fea813be22a9adf69803889b56e5 Mon Sep 17 00:00:00 2001 From: Jack <113976590+bibblobcode@users.noreply.github.com> Date: Wed, 11 Jan 2023 12:34:04 +0000 Subject: [PATCH] CLDC-1796 Add rake task to extract logs data (#1172) For completed logs with illness_type_0 == 1 --- lib/tasks/data_export.rake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/tasks/data_export.rake b/lib/tasks/data_export.rake index 82433756c..5bf9649af 100644 --- a/lib/tasks/data_export.rake +++ b/lib/tasks/data_export.rake @@ -14,3 +14,21 @@ namespace :core do end end end + +namespace :illness_type_0 do + desc "Export log data where illness_type_0 == 1" + task export: :environment do |_task| + logs = LettingsLog.where(illness_type_0: 1, status: "completed").includes(created_by: :organisation) + puts "log_id,created_by_id,organisation_id,organisation_name,startdate" + + logs.each do |log| + puts [ + log.id, + log.created_by_id, + log.created_by.organisation.id, + log.created_by.organisation.name, + log.startdate&.strftime("%d/%m/%Y"), + ].join(",") + end + end +end