From 710e3554de1b4b3b3ecb6c82c4b7e1130a249ffe Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Thu, 23 Jan 2025 14:16:41 -0500 Subject: [PATCH] fix(sql): document user stats calculate for all --- database/document_user_statistics.sql | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/database/document_user_statistics.sql b/database/document_user_statistics.sql index 24be2d5..db4aab0 100644 --- a/database/document_user_statistics.sql +++ b/database/document_user_statistics.sql @@ -1,17 +1,4 @@ -WITH new_activity AS ( - SELECT - document_id, - user_id - FROM activity - WHERE - created_at > COALESCE( - (SELECT MAX(dus.last_seen) FROM document_user_statistics AS dus), - '1970-01-01T00:00:00Z' - ) - GROUP BY user_id, document_id -), - -grouped_activity AS ( +WITH grouped_activity AS ( SELECT ga.user_id, ga.document_id, @@ -91,8 +78,6 @@ grouped_activity AS ( AS weekly_read_percentage FROM activity AS ga - INNER JOIN new_activity AS na - WHERE na.user_id = ga.user_id AND na.document_id = ga.document_id GROUP BY ga.user_id, ga.document_id ),