From 7736e1c828a54a5e5d1237f6e60a86287d28f55d Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 21 Dec 2023 12:00:55 +0200 Subject: [PATCH] Added extra query for log domains destroy events --- app/controllers/repp/v1/stats_controller.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/controllers/repp/v1/stats_controller.rb b/app/controllers/repp/v1/stats_controller.rb index bca81ba78d..b8c3b053fc 100644 --- a/app/controllers/repp/v1/stats_controller.rb +++ b/app/controllers/repp/v1/stats_controller.rb @@ -147,6 +147,22 @@ def domains_by_registrar(date_to) log_domains WHERE event = 'destroy' + AND object_changes->'registrar_id' IS NOT NULL + AND created_at > :date_to + GROUP BY + registrar_id + + UNION ALL + + -- Query for 'destroy' events and count the number of domains destroyed associated with each registrar + SELECT + (object->'registrar_id')::text AS registrar_id, + COUNT(*) AS domain_count + FROM + log_domains + WHERE + event = 'destroy' + AND object_changes IS NULL AND created_at > :date_to GROUP BY registrar_id