mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
update visitId hash and expiration logic
This commit is contained in:
parent
d3ca856521
commit
0aaf2c0b3b
5 changed files with 44 additions and 10 deletions
|
|
@ -1,9 +1,17 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "website_event" ADD COLUMN "visit_id" UUID NULL;
|
||||
|
||||
UPDATE "website_event"
|
||||
SET visit_id = uuid_in(overlay(overlay(md5(CONCAT(session_id::text, to_char(date_trunc('hour', created_at), 'YYYY-MM-DD HH24:00:00'))) placing '4' from 13) placing '8' from 17)::cstring)
|
||||
WHERE visit_id IS NULL;
|
||||
UPDATE "website_event" we
|
||||
SET visit_id = a.uuid
|
||||
FROM (SELECT DISTINCT
|
||||
s.session_id,
|
||||
s.visit_time,
|
||||
gen_random_uuid() uuid
|
||||
FROM (SELECT DISTINCT session_id,
|
||||
date_trunc('hour', created_at) visit_time
|
||||
FROM "website_event") s) a
|
||||
WHERE we.session_id = a.session_id
|
||||
and date_trunc('hour', we.created_at) = a.visit_time;
|
||||
|
||||
ALTER TABLE "website_event" ALTER COLUMN "visit_id" SET NOT NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue