Skip to content

feat: expand Redis caching across bot API routes and web dashboard#346

Merged
BillChirico merged 8 commits intomainfrom
copilot/enhance-redis-caching-project
Mar 24, 2026
Merged

feat: expand Redis caching across bot API routes and web dashboard#346
BillChirico merged 8 commits intomainfrom
copilot/enhance-redis-caching-project

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

  • Explore codebase to understand engagement.js, reputation.js, optout.js, spam.js, linkFilter.js, cache.js, index.js, and test files
  • Items 1+5: Add write-back buffer to engagement.jstrackMessage and trackReaction now synchronously increment in-memory counters; flushEngagementBuffer() batch-upserts all accumulated rows in a single INSERT … ON CONFLICT every 10 s
  • Item 2: Confirmed isOptedOut() already uses an in-memory Set loaded once at startup — zero DB hit per call, no changes needed
  • Items 3+4: Confirmed isSpam() / checkLinks() / role-reward lookups are regex/config-only with no per-message DB queries — no changes needed
  • Wire startEngagementFlushInterval() into startup() (alongside other DB-backed schedulers) and stopEngagementFlushInterval() into gracefulShutdown() before the DB pool closes
  • Rewrite tests/modules/engagement.test.js for the buffered API (26 tests covering buffer accumulation, batch SQL, bumpDays semantics, error recovery, interval lifecycle)
  • All 192 test files pass (3932 tests); coverage above thresholds (91.9% stmts / 85.1% branches / 89.8% fns / 92.9% lines)
  • pnpm lint passes (13 pre-existing web warnings only)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI review requested due to automatic review settings March 20, 2026 19:16
Copilot AI review requested due to automatic review settings March 20, 2026 19:16
@github-project-automation github-project-automation Bot moved this to Backlog in Volvox.Bot Mar 20, 2026
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 20, 2026 19:16 Destroyed
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Mar 20, 2026

🚅 Deployed to the volvox-bot-pr-346 environment in volvox-bot

Service Status Web Updated (UTC)
docs ❌ Build Failed (View Logs) Web Mar 24, 2026 at 10:29 pm
bot ❌ Build Failed (View Logs) Web Mar 24, 2026 at 10:29 pm
web ✅ Success (View Logs) Mar 24, 2026 at 10:28 pm

Copilot AI requested review from Copilot and removed request for Copilot March 20, 2026 19:43
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 20, 2026 19:43 Destroyed
Copilot AI changed the title [WIP] Enhance Redis caching throughout the project feat: expand Redis caching across bot API routes and web dashboard Mar 20, 2026
Copilot AI requested a review from BillChirico March 20, 2026 19:45
Copilot AI review requested due to automatic review settings March 21, 2026 06:55
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 21, 2026 06:55 Destroyed
Copilot AI review requested due to automatic review settings March 21, 2026 06:55
@BillChirico BillChirico added javascript Pull requests that update javascript code scope: backend Bot/runtime/backend logic type: enhancement size:L labels Mar 21, 2026
@BillChirico BillChirico marked this pull request as ready for review March 22, 2026 02:05
Copilot AI review requested due to automatic review settings March 22, 2026 02:05
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@BillChirico
Copy link
Copy Markdown
Collaborator

@coderabbitai review

…e, fix comment precision, guard concurrent interval flushes
… add AI-conversation fallback, fix test mock order, fix lint
Copilot AI review requested due to automatic review settings March 24, 2026 21:48
@BillChirico BillChirico force-pushed the copilot/enhance-redis-caching-project branch from f413ddc to 07f4119 Compare March 24, 2026 21:48
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 24, 2026 21:48 Destroyed
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 24, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 24, 2026

Coverage Status

coverage: 90.149% (-0.004%) from 90.153%
when pulling 088f931 on copilot/enhance-redis-caching-project
into f87e439 on main.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • pnpm-lock.yaml: Language not supported
  • web/pnpm-lock.yaml: Language not supported

Comment thread web/pnpm-lock.yaml
Comment on lines 35 to 50
diff:
specifier: ^8.0.4
version: 8.0.4
specifier: ^8.0.3
version: 8.0.3
framer-motion:
specifier: ^12.38.0
version: 12.38.0(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
lucide-react:
specifier: ^1.6.0
version: 1.6.0(react@19.2.4)
specifier: ^0.577.0
version: 0.577.0(react@19.2.4)
next:
specifier: ^16.2.1
version: 16.2.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
specifier: ^16.2.0
version: 16.2.0(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
next-auth:
specifier: ^4.24.13
version: 4.24.13(next@16.2.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
version: 4.24.13(next@16.2.0(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
next-themes:
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

web/package.json pins deps like next: ^16.2.1, lucide-react: ^1.6.0, diff: ^8.0.4, and includes simple-icons, but web/pnpm-lock.yaml now records different specifiers/versions (e.g. next ^16.2.0, lucide-react ^0.577.0, diff ^8.0.3) and has no simple-icons entry. With pnpm install --frozen-lockfile this will fail. Please regenerate/revert the web lockfile so it matches web/package.json (or commit the corresponding web/package.json changes if the downgrade/removal was intentional).

Copilot uses AI. Check for mistakes.
Comment thread src/modules/engagement.js
@BillChirico
Copy link
Copy Markdown
Collaborator

@claude review

Copilot AI review requested due to automatic review settings March 24, 2026 21:58
@BillChirico BillChirico force-pushed the copilot/enhance-redis-caching-project branch from a485be8 to 11e95ce Compare March 24, 2026 21:58
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 24, 2026 21:58 Destroyed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread src/api/routes/guilds.js
Comment thread src/modules/engagement.js
Comment thread src/modules/engagement.js Outdated
Comment thread src/modules/engagement.js
Comment thread src/api/routes/moderation.js
Comment thread src/utils/cache.js
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 24, 2026 22:09 Destroyed
- engagement.js: add MAX_BUFFER_SIZE (50k) with backpressure, batch inserts (BATCH_SIZE 10k),
  in-flight guard to prevent overlapping flushes, rate-limited error logging (1st + every 30th),
  fix comment (FLUSH_INTERVAL_MS -> DEFAULT_FLUSH_INTERVAL_MS), rethrow on flush failure
- guilds.js: validate channelId as snowflake (digits, max 20 chars) before cache key,
  wrap activeAiConversations query in try/catch with null fallback
- moderation.js: use dedicated TTL.MOD_STATS instead of TTL.LEADERBOARD
- cache.js: add TTL.MOD_STATS, add bot:stats:* to cacheClear() prefixes
- guilds.test.js: fix mock sequence for moved activeAiConversations query,
  update channelId fixtures to valid snowflakes
- reviewHandler.test.js: fix flatMapIdentity lint (biome)
Copilot AI review requested due to automatic review settings March 24, 2026 22:28
@BillChirico BillChirico force-pushed the copilot/enhance-redis-caching-project branch from a76aaa1 to 088f931 Compare March 24, 2026 22:28
@railway-app railway-app Bot temporarily deployed to volvox-bot / volvox-bot-pr-346 March 24, 2026 22:28 Destroyed
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
11.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@BillChirico BillChirico merged commit f936456 into main Mar 24, 2026
15 of 19 checks passed
@BillChirico BillChirico deleted the copilot/enhance-redis-caching-project branch March 24, 2026 22:30
@github-project-automation github-project-automation Bot moved this from In Review to Done in Volvox.Bot Mar 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread src/modules/engagement.js
const messageAuthor = reaction.message.author;
const authorId = messageAuthor?.id;
if (authorId && authorId !== user.id && !messageAuthor?.bot) {
const authorEntry = getOrCreateEntry(guildId, authorId);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getOrCreateEntry() can return null when the buffer hits MAX_BUFFER_SIZE, but trackReaction() unconditionally dereferences authorEntry. If the buffer is at capacity and the reaction author entry is new, this will throw and can break event handling. Guard the author path the same way as the reactor path (only increment when an entry was created).

Suggested change
const authorEntry = getOrCreateEntry(guildId, authorId);
const authorEntry = getOrCreateEntry(guildId, authorId);
if (!authorEntry) return;

Copilot uses AI. Check for mistakes.
Comment thread src/modules/engagement.js
*
* @param {string} guildId
* @param {string} userId
* @returns {StatsEntry}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc for getOrCreateEntry() says @returns {StatsEntry}, but the function returns null when the buffer is full. Update the return type in the doc (and any related annotations) to reflect StatsEntry | null so callers and tooling don’t assume it’s always non-null.

Suggested change
* @returns {StatsEntry}
* @returns {StatsEntry | null}

Copilot uses AI. Check for mistakes.
Comment thread pnpm-lock.yaml
Comment on lines 509 to +526
@@ -522,8 +522,8 @@ packages:
resolution: {integrity: sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==}
engines: {node: '>=16.11.0'}

'@discordjs/rest@2.6.1':
resolution: {integrity: sha512-wwQdgjeaoYFiaG+atbqx6aJDpqW7JHAo0HrQkBTbYzM3/PJ3GweQIpgElNcGZ26DCUOXMyawYd0YF7vtr+fZXg==}
'@discordjs/rest@2.6.0':
resolution: {integrity: sha512-RDYrhmpB7mTvmCKcpj+pc5k7POKszS4E2O9TYc+U+Y4iaCP+r910QdO43qmpOja8LRr1RJ0b3U+CqVsnPqzf4w==}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpm-lock.yaml shows a broad set of transitive version changes (including downgrades like @discordjs/*) without any corresponding package.json change in this PR. Please confirm this lockfile churn is intentional and generated with the repo’s pinned pnpm version; otherwise, consider reverting the lockfile changes to keep the PR focused and reduce the risk of unintended dependency regressions.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code scope: backend Bot/runtime/backend logic size:L

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants