我来看看是怎么个事?
select * from gamification_scores where user_id = 1 order by date desc limit 10;
id | user_id | date | score
----------+---------+------------+-------
26096656 | 1 | 2024-07-31 | 884
25771399 | 1 | 2024-07-30 | 1421
25254851 | 1 | 2024-07-29 | 1009
25183095 | 1 | 2024-07-28 | 347
25534627 | 1 | 2024-07-27 | 306
26041043 | 1 | 2024-07-26 | 1232
25929489 | 1 | 2024-07-25 | 1156
25817985 | 1 | 2024-07-24 | 904
25676931 | 1 | 2024-07-23 | 1436
25526187 | 1 | 2024-07-22 | 741
(10 rows)
select sum(score) from gamification_scores where user_id = 1;
sum
--------
146123
(1 row)
不过我不打算改,那不酷~
听说用这个分数还能做徽章?
SELECT user_id, current_timestamp AS granted_at
FROM gamification_scores
WHERE (:backfill OR user_id IN (:user_ids))
GROUP BY 1
HAVING SUM(score) > 10000