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 ),