Skip to content

Commit

Permalink
rajoute les stats de l'export
Browse files Browse the repository at this point in the history
  • Loading branch information
Josquin Cornec authored and Joalien committed Sep 17, 2024
1 parent 10eacd6 commit f3033ec
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/stats/resources/sql/create_tables_and_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ WHERE logs.token <> 'fakeKeycloak'::text;
--
-- Name: v_log; Type: MATERIALIZED VIEW
--

drop materialized view if exists v_stats;
create materialized view if not exists v_stats as
WITH stat_users AS (SELECT count(DISTINCT v_log.tokencontent ->> 'email'::text) AS users,
date_trunc('month'::text, v_log.date_add) AS mois
Expand All @@ -77,15 +77,22 @@ WITH stat_users AS (SELECT count(DISTINCT v_log.tokencontent ->> 'email'::text)
date_trunc('month'::text, v_log.date_add) AS mois
FROM v_log
GROUP BY (date_trunc('month'::text, v_log.date_add))
LIMIT 100)
LIMIT 100),
stat_export AS (SELECT count(v_log.path) AS export,
date_trunc('month'::text, v_log.date_add) AS mois
FROM v_log
WHERE v_log.path ~~ '/scores/xls/%'::text
GROUP BY (date_trunc('month'::text, v_log.date_add)))
SELECT u.mois,
u.users,
r.recherches,
f.fiches,
v.visites
v.visites,
e.export
FROM stat_users u
JOIN stat_recherches r ON r.mois = u.mois
JOIN stat_fiches f ON f.mois = u.mois
JOIN stat_visites v ON v.mois = u.mois;
JOIN stat_visites v ON v.mois = u.mois
JOIN stat_export e ON e.mois = u.mois;

alter materialized view v_stats owner to postgres;

0 comments on commit f3033ec

Please sign in to comment.