mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: explicit milliseconds precision of timestamp columns
This commit is contained in:
12
scripts/clean_duplicates.sql
Normal file
12
scripts/clean_duplicates.sql
Normal file
@ -0,0 +1,12 @@
|
||||
DELETE t1
|
||||
FROM heartbeats t1
|
||||
INNER JOIN heartbeats t2
|
||||
WHERE t1.id < t2.id
|
||||
AND t1.time = t2.time
|
||||
AND t1.entity = t2.entity
|
||||
AND t1.is_write = t2.is_write
|
||||
AND t1.branch = t2.branch
|
||||
AND t1.editor = t2.editor
|
||||
AND t1.machine = t2.machine
|
||||
AND t1.operating_system = t2.operating_system
|
||||
AND t1.user_id = t2.user_id;
|
@ -1,11 +1,8 @@
|
||||
SELECT s2.user_id, sum(c) as count, total, (sum(c) / total) as ratio
|
||||
FROM (
|
||||
SELECT time,
|
||||
user_id,
|
||||
entity,
|
||||
COUNT(time) as c
|
||||
SELECT time, user_id, entity, is_write, branch, editor, machine, operating_system, COUNT(time) as c
|
||||
FROM heartbeats
|
||||
GROUP BY time, user_id, entity
|
||||
GROUP BY time, user_id, entity, is_write, branch, editor, machine, operating_system
|
||||
HAVING COUNT(time) > 1
|
||||
) s2
|
||||
LEFT JOIN (SELECT user_id, count(id) AS total FROM heartbeats GROUP BY user_id) s3 ON s2.user_id = s3.user_id
|
||||
|
Reference in New Issue
Block a user