fix(sql): document user stats calculate for all
This commit is contained in:
parent
484bdfd7e1
commit
710e3554de
@ -1,17 +1,4 @@
|
|||||||
WITH new_activity AS (
|
WITH grouped_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 (
|
|
||||||
SELECT
|
SELECT
|
||||||
ga.user_id,
|
ga.user_id,
|
||||||
ga.document_id,
|
ga.document_id,
|
||||||
@ -91,8 +78,6 @@ grouped_activity AS (
|
|||||||
AS weekly_read_percentage
|
AS weekly_read_percentage
|
||||||
|
|
||||||
FROM activity AS ga
|
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
|
GROUP BY ga.user_id, ga.document_id
|
||||||
),
|
),
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user