Discourse Daily Challenges

I am currently taking my daughter to school. And then I have a few appointments this morning. It will take me some time to investigate.

1 Like

It looks like some database columns may not have migrated properly. This version added several new columns to the existing tables. Can you try running:

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

Using the in-panel Update button doesn’t apply database migrations — a full rebuild is required when the plugin adds new columns.

Thanks for being patient. We’ll get it figured out!

1 Like

Actually, can you run this first and post the output?

./launcher enter app
su discourse -c 'cd /var/www/discourse && bundle exec rails runner "puts ActiveRecord::Base.connection.columns(\"daily_challenges\").map(&:name)"'
1 Like
root@segredin-app:/var/www/discourse# su discourse -c 'cd /var/www/discourse && bundle exec rails runner "puts ActiveRecord::Base.connection.columns(\"daily_challenges\").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

look this

ActiveModel::UnknownAttributeError (unknown attribute 'challenge_timezone' for DailyChallenge.) app/controllers/application_controller.rb:447:in 'block in ApplicationController#with_resolved_locale'

It looks like you are missing the challenge_timezone DB column. Can you run this:

./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)"'

That should add it. I will investigate why it didn’t get added and update files.

1 Like

Alright, remains but I’ll wait for his fix

ActiveModel::UnknownAttributeError (unknown attribute 'challenge_timezone' for DailyChallenge.)
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'

Just to make sure we are in the right directory, run this first:

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

Then run this:

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)"'

After you rn that, you can type “exit” to get out of the app.

Do a hard refresh on the webpage (ctrl-shift-R) and try again. If that doesn;t work, I will be pushing a fix in a few.

I am in a meeting. I’ll update soon.

1 Like

I just pushed an update. You should be able to update via the admin panel. If that doesn’t work, you might have to do

./launcher rebuild app
1 Like

It Works

Friends: Chandler Bing (Matthew Perry) Dancing

1 Like

WOOOO!!! Thanks for sticking with me and helping me work through it!!

Funny Man Dancing in Tutu

1 Like

So next step have some new functions ahead? I wish to give you some ideas

Streaks with coins and badges and a place/section to follow up own stats

Anyway I love it and I waiting for more :smiley:

1 Like

I am currently working on this part. It will basically be a “bot” that you create (really just a user account). The plugin will watch for mentions of the bot. When it sees them, it will execute the action. For example:

Bot Name: ChallengeBot

Someone types:

@ChallengeBot status

The bot will send them a DM with their current status in the challenge.

The bot will also have some other options as well.

1 Like

Has how get this info to show it in another place ? or make it appear at card user? If have some path to do it would be nice

v1.4.0 is now available!

This release adds ChallengeBot — an optional bot account that brings DM-powered engagement features to your challenges.

New in this release:

  • Check-in confirmation DMs — members receive a DM from ChallengeBot after every successful check-in, showing their current streak and a link to the challenge topic.
  • Reminder DMs — participants who haven’t checked in for 2+ consecutive days (daily challenges) or haven’t checked in by the last day of the week (weekly challenges) receive a gentle nudge from ChallengeBot. Includes their current check-in count and goal. Toggle per challenge, defaults to enabled.
  • @mention commands — members can mention @ChallengeBot in any active challenge topic to get personal stats via DM. The bot never replies in the topic itself. Available commands: status, leaderboard, streak, checkins, progress, help. Rate limited to 10 commands per user per hour.
  • Leaderboard and final results posts — if ChallengeBot is configured, weekly leaderboard posts and final results posts are now sent from the bot account instead of the system account.
  • New site settingdaily_challenge_bot_username
  • New challenge field — reminder DMs toggle (defaults to enabled)

Setting up ChallengeBot is optional — all existing features continue to work without it. See the main post for full setup instructions.

Note: This release includes a database migration. The in-panel Update button will apply it automatically.