Merge pull request #2632 from internetee/improve-statistics

Improved stats query
This commit is contained in:
Timo Võhmar 2023-12-22 11:08:50 +02:00 committed by GitHub
commit f2bad50884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 20 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

@ -1,5 +1,5 @@
Name,Registrant,Registrar,Action,Created at
,John,,destroy,2023-12-04 22:00:00
,John,Good Names,destroy,2023-12-04 22:00:00
hospital.test,John,Good Names,create,2023-12-04 22:00:00
library.test,Acme Ltd,Best Names,create,2023-12-04 22:00:00
shop.test,John,Best Names,update,2023-12-04 22:00:00

1 Name Registrant Registrar Action Created at
2 John Good Names destroy 2023-12-04 22:00:00
3 hospital.test John Good Names create 2023-12-04 22:00:00
4 library.test Acme Ltd Best Names create 2023-12-04 22:00:00
5 shop.test John Best Names update 2023-12-04 22:00:00

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: