MikeNolan
(Mike Nolan)
2025 年1 月 30 日 03:46
1
我们的 Discourse 论坛的一位成员询问 Discourse 是否有方法显示/识别在 Discourse 论坛上连续访问或发帖的天数。我在管理员的用户信息中没有看到任何此类信息,它被保存在哪里了吗?
供参考,Reddit 有此功能。
1 个赞
是的,因为有“Enthusiast”(爱好者)、“Aficionado”(狂热者)和“Devotee”(信徒)等徽章,它们是针对连续访问天数。据我回忆,“visited”(访问)是指点赞帖子/回复过一次。
3 个赞
Lilly
(Lillian Louis)
2025 年1 月 30 日 04:23
3
你也许可以做一个数据探索查询。user_visits 表的 schema 在这里:
# == Schema Information
#
# Table name: user_visits
#
# id :integer not null, primary key
# user_id :integer not null
# visited_at :date not null
# posts_read :integer default(0)
# mobile :boolean default(FALSE)
# time_read :integer default(0), not null
#
# Indexes
#
# index_user_visits_on_user_id_and_visited_at (user_id,visited_at) UNIQUE
# index_user_visits_on_user_id_and_visited_at_and_time_read (user_id,visited_at,time_read)
# index_user_visits_on_visited_at_and_mobile (visited_at,mobile)
#
也许像这样?
WITH consecutive_visits AS (
SELECT
user_id,
visited_at,
visited_at - INTERVAL '1 day' * ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY visited_at) AS grp
FROM
user_visits
),
visit_streaks AS (
SELECT
user_id,
COUNT(*) AS streak_length
FROM
consecutive_visits
GROUP BY
user_id, grp
)
SELECT
user_id,
MAX(streak_length) AS longest_streak
FROM
visit_streaks
GROUP BY
user_id
ORDER BY
longest_streak DESC
LIMIT 100
或者也许你可以结合 user_actions 表(带有点赞和帖子的访问记录?),它在这里:
# Table name: user_actions
#
# id :integer not null, primary key
# action_type :integer not null
# user_id :integer not null
# target_topic_id :integer
# target_post_id :integer
# target_user_id :integer
# acting_user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# idx_unique_rows (action_type,user_id,target_topic_id,target_post_id,acting_user_id) UNIQUE
# idx_user_actions_speed_up_user_all (user_id,created_at,action_type)
# index_user_actions_on_acting_user_id (acting_user_id)
# index_user_actions_on_action_type_and_created_at (action_type,created_at)
# index_user_actions_on_target_post_id (target_post_id)
# index_user_actions_on_target_user_id (target_user_id) WHERE (target_user_id IS NOT NULL)
This file has been truncated. show original
3 个赞
system
(system)
关闭
2025 年3 月 1 日 04:29
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.