Switch discord channels to exclusion list
What does this MR do and why?
Discord channel ingestion was controlled by a hardcoded inclusion list (DiscordMessage::CHANNELS), so any new channel (e.g. a hackathon channel) went untracked until someone remembered to add it, undercounting contributors' "discuss" activity.
This MR switches to an exclusion-list model, plus a safety-net alert for channels nobody has looked at yet:
DiscordService#guild_channelsfetches all live text channels from the guild via the Discord API (GET /guilds/{guild_id}/channels), instead of relying on a static id list.DiscordMessage::CHANNELSis replaced byDiscordMessage::EXCLUDED_CHANNELS(id list). Every channel is ingested by default now; only channels listed there are skipped.- Added a
channel_namecolumn todiscord_messages, populated at ingest time from the API response, so channel display names work for any channel. Backfilled the 4 previously-tracked channels' names in the migration. data:discordrake task now loops overguild_channels, skipping anything inEXCLUDED_CHANNELS.- New
data:discord_channel_checkrake task +discord-channel-checkCI job (gated by$EXECUTE_DISCORD_CHANNEL_CHECK): compares live guild channels against channels that are already ingested or excluded, and fails the job listing any that are neither. - Seeded
EXCLUDED_CHANNELSwith the inverted selection of previously included channels (#observability,#off-topic,#discord,#thanks,#help-request-notifications,#welcome).
Changelog: Maintenance
Validation steps
bundle exec rspec spec/models/discord_message_spec.rb spec/services/discord_service_spec.rb spec/tasks/data_spec.rb spec/presenters/users/profile_presenter_spec.rball green.bundle exec rubocopon the changed files, no offenses.bundle exec rails db:migrateapplies cleanly and backfillschannel_namefor the 4 previously-known channels;bundle exec rails db:rollbackcleanly drops the column.- In a Rails console, stub
HTTParty.getto return a fakeguild_channelsresponse including a channel not inEXCLUDED_CHANNELS, then runRake::Task['data:discord'].invoke('1')to confirmfetch_all_messagesis called for the new channel without any code change. - Run
bundle exec rake data:discord_channel_checkagainst a guild with an unclassified channel, confirms it prints the channel name/id and exits non-zero (CI job goes red).
Closes #528 (closed)