Files
bl/help/内测奖励查询.sql
昔念 026689f3ed ```
feat(cache): 添加复合键缓存操作支持

添加了基于 uint32+string 组合键的缓存操作方法,包括
GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和
ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景

fix(vscode): 添加 cSpell 配置支持 struc 词汇

refactor(session): 移除过时的会话管理方法

移除了基于单一字符串键的会话管理方法,因为已迁移到使用
复合键的缓存操作方式
```
2026-01-19 18:51:56 +08:00

42 lines
2.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 整合所有用户核心指标任务数击杀数在线时长胜利数最高关卡最高刷新关卡
SELECT
COALESCE(t1.player_id, t2.player_id, t3.player_id, t4.player_id, t5.player_id, t6.player_id) AS player_id,
-- 处理NULL值无数据时显示0
COALESCE(t1.task_count, 0) AS task_count, -- player_task表的任务数量
COALESCE(t2.catch_kill_count, 0) AS catch_kill_count, -- player_catch_kill_count表的击杀数量
COALESCE(t3.online_time, 0) AS online_time, -- 在线时长
COALESCE(t4.mess_win, 0) AS mess_win, -- 胜利次数
COALESCE(t5.max_stage, 0) AS max_stage, -- 最高关卡
COALESCE(t6.max_fresh_stage, 0) AS max_fresh_stage -- 最高刷新关卡
FROM
-- 子查询1统计player_task表的用户任务数
(SELECT player_id, COUNT(*) AS task_count
FROM player_task
GROUP BY player_id) t1
FULL OUTER JOIN
-- 子查询2统计player_catch_kill_count表的用户击杀数
(SELECT player_id, COUNT(*) AS catch_kill_count
FROM player_catch_kill_count
GROUP BY player_id) t2 ON t1.player_id = t2.player_id
FULL OUTER JOIN
-- 子查询3提取player_info表的在线时长>0
(SELECT player_id, (data->>'online_time')::int AS online_time
FROM player_info
WHERE jsonb_exists(data, 'online_time') AND (data->>'online_time')::int > 0) t3 ON COALESCE(t1.player_id, t2.player_id) = t3.player_id
FULL OUTER JOIN
-- 子查询4提取player_info表的胜利次数mess_win >0
(SELECT player_id, (data->>'mess_win')::int AS mess_win
FROM player_info
WHERE jsonb_exists(data, 'mess_win') AND (data->>'mess_win')::int > 0) t4 ON COALESCE(t1.player_id, t2.player_id, t3.player_id) = t4.player_id
FULL OUTER JOIN
-- 子查询5提取player_info表的最高关卡max_stage >0
(SELECT player_id, (data->>'max_stage')::int AS max_stage
FROM player_info
WHERE jsonb_exists(data, 'max_stage') AND (data->>'max_stage')::int > 0) t5 ON COALESCE(t1.player_id, t2.player_id, t3.player_id, t4.player_id) = t5.player_id
FULL OUTER JOIN
-- 子查询6提取player_info表的最高刷新关卡max_fresh_stage >0
(SELECT player_id, (data->>'max_fresh_stage')::int AS max_fresh_stage
FROM player_info
WHERE jsonb_exists(data, 'max_fresh_stage') AND (data->>'max_fresh_stage')::int > 0) t6 ON COALESCE(t1.player_id, t2.player_id, t3.player_id, t4.player_id, t5.player_id) = t6.player_id
-- 可选按某一指标排序比如在线时长降序
ORDER BY online_time DESC;