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
-- 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
SELECT
(object->'registrar_id')::text AS registrar_id,
@ -162,7 +147,7 @@ module Repp
log_domains
WHERE
event = 'destroy'
AND object_changes IS NULL
AND object IS NOT NULL
AND created_at > :date_to
GROUP BY
registrar_id

View file

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