-- Neo4j 图数据导出 - 简洁版
-- 节点: User(mid), Video(vid), Share(shareid)
-- 关系: CREATED(User→Share), OF(Share→Video), CLICKED(User→Share)
-- 使用 fetch_daily.py 按天获取
--
-- 字段说明：
--   action_type: share=分享事件, click=点击事件
--   actor_mid: 执行动作的用户（share时是分享者，click时是点击者）
--   sharer_mid: 创建 shareid 的用户（从 shareid 提取）
--   注: share事件时 actor_mid = sharer_mid

SELECT
    topic as action_type,
    shareid,
    rootshareid,
    sharedepth,
    CASE
        WHEN topic = 'share' THEN shareobjectid
        WHEN topic = 'click' THEN clickobjectid
    END as vid,
    machinecode as actor_mid,
    split(shareid, '-')[0] as sharer_mid,
    clienttimestamp as action_ts
FROM loghubods.user_share_log
WHERE dt = '${dt}'
    AND topic IN ('share', 'click')
    AND shareid IS NOT NULL
