data layer
This commit is contained in:
57
data-layer/infra/clickhouse/profile_timeline.sql.tmpl
Normal file
57
data-layer/infra/clickhouse/profile_timeline.sql.tmpl
Normal file
@@ -0,0 +1,57 @@
|
||||
-- Profile timeline -- merged event stream for one user_id within a workspace.
|
||||
--
|
||||
-- Required parameters (clickhouse.Named):
|
||||
-- workspace_id : String
|
||||
-- user_id : String
|
||||
-- limit : UInt32
|
||||
-- offset : UInt32
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
'track' AS kind,
|
||||
message_id,
|
||||
event AS name,
|
||||
received_at,
|
||||
properties AS payload
|
||||
FROM events_track
|
||||
WHERE workspace_id = {workspace_id:String}
|
||||
AND user_id = {user_id:String}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'identify' AS kind,
|
||||
message_id,
|
||||
'' AS name,
|
||||
received_at,
|
||||
traits AS payload
|
||||
FROM events_identify
|
||||
WHERE workspace_id = {workspace_id:String}
|
||||
AND user_id = {user_id:String}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'page' AS kind,
|
||||
message_id,
|
||||
name AS name,
|
||||
received_at,
|
||||
properties AS payload
|
||||
FROM events_page
|
||||
WHERE workspace_id = {workspace_id:String}
|
||||
AND user_id = {user_id:String}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'group' AS kind,
|
||||
message_id,
|
||||
'' AS name,
|
||||
received_at,
|
||||
traits AS payload
|
||||
FROM events_group
|
||||
WHERE workspace_id = {workspace_id:String}
|
||||
AND user_id = {user_id:String}
|
||||
)
|
||||
ORDER BY received_at DESC
|
||||
LIMIT {limit:UInt32}
|
||||
OFFSET {offset:UInt32}
|
||||
Reference in New Issue
Block a user