实现 value_rank 首版插件并接入定时重算
- 新增 ValueRank 插件入口、配置与主逻辑(我的身价/身价排行/身价说明/重算身价) - 新增每日 04:00 调度动作,支持按群批量重算并写入快照 - 实现积分/发言/活跃/社交四维打分与潜水惩罚,采用95分位截断与归一化 - 新增 t_value_rank_snapshot 建表迁移脚本,并同步更新 init.sql - 代码中补充详细中文注释,说明算法意图、边界处理与稳定性策略
This commit is contained in:
@@ -520,6 +520,31 @@ create or replace table message_archive.t_user_stats
|
||||
)
|
||||
comment '用户使用统计表';
|
||||
|
||||
create or replace table message_archive.t_value_rank_snapshot
|
||||
(
|
||||
id bigint auto_increment
|
||||
primary key,
|
||||
stat_date date not null comment '统计日期',
|
||||
group_id varchar(100) not null comment '群ID',
|
||||
user_id varchar(100) not null comment '用户ID',
|
||||
score decimal(10, 2) default 0.00 not null comment '身价分',
|
||||
rank_no int default 0 not null comment '排名',
|
||||
title varchar(50) default '' not null comment '称号',
|
||||
points_total int default 0 not null comment '积分存量',
|
||||
msg_count_7d int default 0 not null comment '7日发言数',
|
||||
active_days_30 int default 0 not null comment '30日活跃天数',
|
||||
inactive_days int default 0 not null comment '距今未发言天数',
|
||||
score_detail_json json null comment '分项得分明细',
|
||||
created_at datetime default current_timestamp() not null comment '创建时间',
|
||||
updated_at datetime default current_timestamp() not null on update current_timestamp() comment '更新时间',
|
||||
constraint uniq_day_group_user
|
||||
unique (stat_date, group_id, user_id)
|
||||
)
|
||||
comment '身价日快照表';
|
||||
|
||||
create or replace index idx_group_day_rank
|
||||
on message_archive.t_value_rank_snapshot (group_id, stat_date, rank_no);
|
||||
|
||||
create or replace index idx_last_used_at
|
||||
on message_archive.t_user_stats (last_used_at);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Value Rank 主快照表:用于每日身价结果持久化与趋势对比
|
||||
CREATE TABLE IF NOT EXISTS message_archive.t_value_rank_snapshot (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
stat_date DATE NOT NULL COMMENT '统计日期',
|
||||
group_id VARCHAR(100) NOT NULL COMMENT '群ID',
|
||||
user_id VARCHAR(100) NOT NULL COMMENT '用户ID',
|
||||
score DECIMAL(10,2) NOT NULL DEFAULT 0 COMMENT '身价分',
|
||||
rank_no INT NOT NULL DEFAULT 0 COMMENT '排名',
|
||||
title VARCHAR(50) NOT NULL DEFAULT '' COMMENT '称号',
|
||||
points_total INT NOT NULL DEFAULT 0 COMMENT '积分存量',
|
||||
msg_count_7d INT NOT NULL DEFAULT 0 COMMENT '7日发言数',
|
||||
active_days_30 INT NOT NULL DEFAULT 0 COMMENT '30日活跃天数',
|
||||
inactive_days INT NOT NULL DEFAULT 0 COMMENT '距今未发言天数',
|
||||
score_detail_json JSON NULL COMMENT '分项得分明细',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uniq_day_group_user (stat_date, group_id, user_id),
|
||||
KEY idx_group_day_rank (group_id, stat_date, rank_no)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='身价日快照表';
|
||||
Reference in New Issue
Block a user