每日 Discourse 挑战

我正在送女儿去学校。然后我今天上午还有几个预约。我需要一些时间来调查。

1 个赞

看起来某些数据库列可能未正确迁移。此版本为现有表添加了多个新列。请尝试运行以下命令:

cd /var/discourse && ./launcher rebuild app

使用面板中的“更新”按钮不会应用数据库迁移——当插件添加新列时,需要进行完整重建。

感谢您的耐心。我们会尽快解决这个问题!

1 个赞

实际上,你能先运行这个并贴出输出吗?

./launcher enter app
su discourse -c 'cd /var/www/discourse && bundle exec rails runner "puts ActiveRecord::Base.connection.columns(\"daily_challenges\").map(&:name)"'
1 个赞
root@segredin-app:/var/www/discourse# su discourse -c 'cd /var/www/discourse &&                                                                                         bundle exec rails runner "puts ActiveRecord::Base.connection.columns(\"daily_cha                                                                                        llenges\").map(&:name)"'
id
topic_id
hashtag
start_date
end_date
check_ins_needed
description
created_at
updated_at
final_post_sent
weekly_post_enabled
weekly_post_day
weekly_post_hour
award_badge
badge_name
badge_id
check_in_interval
week_start
category_id

查看此错误

ActiveModel::UnknownAttributeError(DailyChallenge 的未知属性 'challenge_timezone')app/controllers/application_controller.rb:447:in 'block in ApplicationController#with_resolved_locale'

看起来您缺少 challenge_timezone 数据库列。您可以运行以下命令:

./launcher enter app
su discourse -c 'cd /var/www/discourse && bundle exec rails runner "ActiveRecord::Base.connection.add_column(:daily_challenges, :challenge_timezone, :string, default: \"UTC\") unless ActiveRecord::Base.connection.column_exists?(:daily_challenges, :challenge_timezone)"'

这应该会添加该列。我将调查为何未自动添加,并更新相关文件。

1 个赞

好的,只剩下等待他的修复了

ActiveModel::UnknownAttributeError (DailyChallenge 的未知属性 'challenge_timezone')
app/controllers/application_controller.rb:447:in 'block in ApplicationController#with_resolved_locale'
app/controllers/application_controller.rb:447:in 'ApplicationController#with_resolved_locale'
app/controllers/application_controller.rb:1098:in 'ApplicationController#ensure_dont_cache_page'
lib/middleware/omniauth_bypass_middleware.rb:35:in 'Middleware::OmniauthBypassMiddleware#call'
lib/middleware/crawler_hooks.rb:11:in 'Middleware::CrawlerHooks#call'
lib/content_security_policy/middleware.rb:12:in 'ContentSecurityPolicy::Middleware#call'
lib/middleware/anonymous_cache.rb:420:in 'Middleware::AnonymousCache#call'
lib/middleware/csp_script_nonce_injector.rb:12:in 'Middleware::CspScriptNonceInjector#call'
config/initializers/008-rack-cors.rb:14:in 'Discourse::Cors#call'
lib/middleware/default_headers.rb:13:in 'Middleware::DefaultHeaders#call'
config/initializers/100-quiet_logger.rb:20:in 'DiscourseRackQuietAssetsLogger#call'
config/initializers/100-silence_logger.rb:29:in 'SilenceLogger#call'
lib/middleware/enforce_hostname.rb:23:in 'Middleware::EnforceHostname#call'
lib/middleware/request_tracker.rb:321:in 'Middleware::RequestTracker#call'
lib/middleware/overload_protections.rb:22:in 'Middleware::OverloadProtections#call'
lib/middleware/processing_request.rb:14:in 'Middleware::ProcessingRequest#call'

为确保我们处于正确的目录,请先运行以下命令:

cd /var/discourse && ./launcher enter app

然后运行以下命令:

su discourse -c 'cd /var/www/discourse && bundle exec rails runner "ActiveRecord::Base.connection.add_column(:daily_challenges, :challenge_timezone, :string, default: \"UTC\") unless ActiveRecord::Base.connection.column_exists?(:daily_challenges, :challenge_timezone)"'

运行完成后,您可以输入“exit”退出应用。

对网页进行硬刷新(Ctrl+Shift+R)后重试。如果仍然无效,我将在几分钟后推送修复。

我正在开会。我稍后会更新。

1 个赞

我刚刚推送了一个更新。您应该可以通过管理面板进行更新。如果不起作用,您可能需要执行以下操作:

./launcher rebuild app
1 个赞

它有效

Friends: Chandler Bing (Matthew Perry) Dancing

1 个赞

哇!!!感谢您一直陪伴我并帮助我解决这个问题!!

Funny Man Dancing in Tutu

1 个赞

那么下一步会有新功能吗?我想给你一些建议:

带有硬币和徽章的连胜系统,以及一个可以追踪个人统计数据的区域/板块。

无论如何,我很喜欢它,期待更多内容 :smiley:

1 个赞

我目前正在开发这一部分。它本质上是一个您可以创建的“机器人”(实际上只是一个用户账户)。该插件将监控对该机器人的提及。当它检测到提及时,将执行相应操作。例如:

机器人名称:ChallengeBot

有人输入:

@ChallengeBot status

机器人将向其发送一条私信,告知其在挑战中的当前状态。

该机器人还将提供其他一些选项。

1 个赞

如何将此信息显示在其他位置?或者让它出现在用户卡片上?如果有实现方法就太好了。

v1.4.0 现已发布!

本次更新引入了 ChallengeBot——一个可选的机器人账户,为您的挑战活动提供基于私信(DM)的互动功能。

本次更新新增内容:

  • 签到确认私信 — 成员每次成功签到后,都会收到来自 ChallengeBot 的私信,显示当前的连续签到天数及挑战主题链接。
  • 提醒私信 — 对于未连续签到 2 天或以上的参与者(每日挑战),或未在本周最后一天前签到的参与者(每周挑战),ChallengeBot 会发送温和的提醒。消息中包含当前的签到次数和目标。可按挑战单独开启或关闭,默认启用。
  • @提及命令 — 成员可在任何活跃的挑战主题中提及 @ChallengeBot,以通过私信获取个人统计数据。机器人不会在主题内直接回复。可用命令包括:statusleaderboardstreakcheckinsprogresshelp。频率限制为每小时每用户最多 10 条命令。
  • 排行榜和最终结果帖子 — 如果配置了 ChallengeBot,每周的排行榜帖子和最终结果帖子现在将由机器人账户发送,而非系统账户。
  • 新增站点设置daily_challenge_bot_username
  • 新增挑战字段 — 提醒私信开关(默认启用)

设置 ChallengeBot 是可选的——所有现有功能在不使用它的情况下仍可正常运行。完整设置说明请参阅主帖中的 设置指南

注意: 本次更新包含数据库迁移。面板中的“更新”按钮将自动应用此迁移。

2 个赞

太棒了 :smiley:

如果将其发送到私信或在主题中发送,此选项是否可行?顺便说一下,我已将 @system 设置为聊天机器人。

CSS

.daily-challenge-dashboard {
    background-color: #1a1a1b;
    padding: 20px;
    border-radius: 8px;
    color: #d7dadc;
}

.d-page-subheader__title {
    color: #ffffff;
    font-size: 1.5rem;
    margin-bottom: 15px;
    border-bottom: 1px solid #343536;
    padding-bottom: 10px;
}

.d-stat-tiles.fcd-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 30px;
}

.d-stat-tile {
    background-color: #272729;
    border: 1px solid #343536;
    padding: 15px;
    border-radius: 8px;
    transition: border-color 0.2s;
}

.d-stat-tile:hover {
    border-color: #818384;
}

.d-stat-tile__label {
    color: #818384;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.d-stat-tile__value {
    display: block;
    font-size: 1.8rem;
    font-weight: 600;
    color: #ff4500;
}

.fcd-leaderboard__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.fcd-leaderboard__table thead th {
    color: #818384;
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 0 15px 5px 15px;
    text-align: left;
}

.fcd-leaderboard__row {
    background-color: #272729;
    transition: transform 0.1s ease;
}

.fcd-leaderboard__row td {
    padding: 12px 15px;
    border-top: 1px solid #343536;
    border-bottom: 1px solid #343536;
}

.fcd-leaderboard__row td:first-child {
    border-left: 1px solid #343536;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.fcd-leaderboard__row td:last-child {
    border-right: 1px solid #343536;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.fcd-leaderboard__row:hover {
    background-color: #2d2d2e;
}

.fcd-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.8rem;
}

.fcd-rank--gold { background: #ffd700; color: #000; box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
.fcd-rank--silver { background: #c0c0c0; color: #000; }

.fcd-streak-icon {
    color: #ff4500;
    filter: drop-shadow(0 0 3px rgba(255, 69, 0, 0.5));
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.fcd-progress {
    height: 8px;
    background-color: #343536;
    border-radius: 4px;
    overflow: hidden;
    width: 100px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.fcd-progress__bar {
    background: linear-gradient(90deg, #ff4500, #ff8c00);
    height: 100%;
    border-radius: 4px;
}

.fcd-progress__label {
    font-size: 0.8rem;
    color: #d7dadc;
    font-weight: bold;
}

.fcd-leaderboard__user img {
    border-radius: 50%;
    border: 2px solid #343536;
    margin-right: 10px;
}