Improved stats query

This commit is contained in:
Sergei Tsoganov 2023-12-21 17:26:01 +02:00
parent 8cef623888
commit c67a21c7ba
2 changed files with 2 additions and 19 deletions

View file

@ -139,21 +139,6 @@ module Repp
UNION ALL UNION ALL
-- Query for 'destroy' events and count the number of domains destroyed associated with each registrar
SELECT
(object_changes->'registrar_id'->>0)::text AS registrar_id,
COUNT(*) AS domain_count
FROM
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 -- Query for 'destroy' events and count the number of domains destroyed associated with each registrar
SELECT SELECT
(object->'registrar_id')::text AS registrar_id, (object->'registrar_id')::text AS registrar_id,
@ -162,7 +147,7 @@ module Repp
log_domains log_domains
WHERE WHERE
event = 'destroy' event = 'destroy'
AND object_changes IS NULL AND object IS NOT NULL
AND created_at > :date_to AND created_at > :date_to
GROUP BY GROUP BY
registrar_id registrar_id

View file

@ -74,9 +74,7 @@ destroy_one:
event: destroy event: destroy
object: object:
registrant_id: <%= ActiveRecord::FixtureSet.identify(:john) %> registrant_id: <%= ActiveRecord::FixtureSet.identify(:john) %>
object_changes: registrar_id: <%= ActiveRecord::FixtureSet.identify(:goodnames) %>
name: ['cinema.test', null]
registrar_id: [<%= ActiveRecord::FixtureSet.identify(:goodnames) %>, null]
created_at: <%= Time.zone.parse('2023-12-05') %> created_at: <%= Time.zone.parse('2023-12-05') %>
create_six: create_six: