Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Feb 7, 2025
1 parent f472e09 commit 1b4d56c
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lib/model/query/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,19 +495,16 @@ const getDatasets = () => ({ all }) => all(sql`
GROUP BY e."datasetId"
) AS updates ON ds.id = updates."datasetId"
LEFT JOIN (
SELECT
-- not used: COUNT (*) total,
-- not used: SUM (CASE WHEN a."loggedAt" >= ${_cutoffDate} THEN 1 ELSE 0 END) recent,
COUNT(a.details->'submissionDefId') AS create_sub_total,
COUNT(a.details->'submissionDefId' IS NOT NULL AND a."loggedAt" >= ${_cutoffDate} OR NULL) AS create_sub_recent,
COUNT(a.details->'submissionDefId' IS NULL OR NULL) AS create_api_total,
COUNT(a.details->'submissionDefId' IS NULL AND a."loggedAt" >= ${_cutoffDate} OR NULL) AS create_api_recent,
e."datasetId"
FROM audits a
JOIN entities e on (a.details->'entityId')::INT = e.id
WHERE a."action" = 'entity.create'
GROUP BY e."datasetId"
) as creates ON ds.id = creates."datasetId"
SELECT COUNT(a.details->'submissionDefId') AS create_sub_total
, COUNT(a.details->'submissionDefId' IS NOT NULL AND a."loggedAt" >= ${_cutoffDate} OR NULL) AS create_sub_recent
, COUNT(a.details->'submissionDefId' IS NULL OR NULL) AS create_api_total
, COUNT(a.details->'submissionDefId' IS NULL AND a."loggedAt" >= ${_cutoffDate} OR NULL) AS create_api_recent
, e."datasetId"
FROM audits AS a
JOIN entities AS e on (a.details->'entityId')::INT = e.id
WHERE a."action" = 'entity.create'
GROUP BY e."datasetId"
) AS creates ON ds.id = creates."datasetId"
LEFT JOIN (
SELECT COUNT(*) total,
SUM (CASE WHEN a."loggedAt" >= ${_cutoffDate} THEN 1 ELSE 0 END) recent,
Expand Down

0 comments on commit 1b4d56c

Please sign in to comment.