refactor: consolidate PollSettings/PollWithOptions types, remove dead code, add CI - #19
Conversation
|
Warning Review limit reached
More reviews will be available in 15 minutes and 51 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (26)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR applies a set of low-risk code-quality cleanups by consolidating poll-related types (PollWithOptions, PollSettings), removing verified-dead code, centralizing duplicated constants, and adding a CI workflow that type-checks the project on PRs and main pushes.
Changes:
- Replaced hand-written/cast-heavy poll payload types with
Prisma.PollGetPayloadderived from a singlepollInclude, and centralized poll settings parsing/defaults viagetSettings(). - Removed unused helpers (
buildResultsDM,renderTextBar,renderResultsText,getButtonEmoji) and deduplicatedPOLL_TYPE_LABELSintosrc/constants.ts. - Added GitHub Actions CI to run
npm ci,prisma generate, andtsc --noEmit.
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/views/pollEditSubmission.ts | Replaces local PollSettings with shared type import. |
| src/views/pollCreationSubmission.ts | Removes dynamic import and uses shared PollSettings + static updatePollMessageTs import. |
| src/views/pollCreationModal.ts | Uses centralized POLL_TYPE_LABELS for poll-type select labels. |
| src/utils/emojiPrefix.ts | Removes unused getButtonEmoji alias. |
| src/utils/barChart.ts | Removes unused text-rendering helpers. |
| src/types/pollSettings.ts | Adds shared PollSettings + getSettings() defaulting helper. |
| src/services/pollService.ts | Consolidates PollWithOptions using pollInclude + removes unsafe casts. |
| src/jobs/startupRecovery.ts | Uses getSettings() instead of inline settings casts. |
| src/jobs/scheduledPollJob.ts | Uses getSettings() instead of inline settings casts. |
| src/jobs/reminderJob.ts | Uses getSettings() instead of inline settings casts. |
| src/jobs/autoCloseJob.ts | Uses getSettings() instead of inline settings casts. |
| src/constants.ts | Adds centralized POLL_TYPE_LABELS. |
| src/commands/askify.ts | Uses centralized POLL_TYPE_LABELS instead of local maps. |
| src/blocks/resultsDM.ts | Switches to shared PollSettings type import. |
| src/blocks/pollMessage.ts | Uses shared PollSettings + centralized POLL_TYPE_LABELS; removes dead buildResultsDM. |
| src/actions/voteAction.ts | Uses getSettings() instead of inline settings cast. |
| src/actions/templateActions.ts | Uses getSettings() when building template config. |
| src/actions/shareResultsAction.ts | Uses getSettings() instead of inline settings cast. |
| src/actions/repostAction.ts | Uses getSettings() instead of inline settings cast. |
| src/actions/listActions.ts | Uses getSettings() instead of inline settings casts. |
| src/actions/editPollAction.ts | Uses getSettings() instead of inline settings cast. |
| src/actions/closePollAction.ts | Uses getSettings() instead of inline settings cast. |
| src/actions/addOptionAction.ts | Uses getSettings() instead of inline settings cast. |
| package.json | Removes unused deps (uuid, @types/uuid) and moves prisma CLI to devDependencies. |
| package-lock.json | Lockfile refresh reflecting dependency cleanup/reclassification. |
| CLAUDE.md | Updates docs to reflect new types, settings helper, and action ID prefixes. |
| .github/workflows/ci.yml | Adds CI workflow for install → prisma generate → typecheck. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| options: poll.options.map((o) => o.label), | ||
| ...(description ? { description } : {}), | ||
| settings, | ||
| settings: settings as TemplateConfig['settings'], |
…casting Addresses review feedback on #19 https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Re-applies getSettings()/shared types over main's atomic claims, fresh-poll re-fetch, and unique-voter threading; drops the dead buildResultsDM and countUniqueVoters helpers from both sides. https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Re-applies getSettings()/shared constants over the new ownership checks and mrkdwn escaping; keeps buildResultsDM deleted. https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Keeps the dead buildResultsDM deleted; resilience changes merge cleanly over the consolidated types. https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Fixes #14
Low-risk code-quality cleanups from the codebase audit (27 files, +232/−359). The larger deduplication refactor (close-poll flow ×4, submission parsing ×2, results rendering ×3) is intentionally deferred to a follow-up after the bug-fix PRs (#15–#18) merge, to avoid conflicts.
Type consolidation
PollWithOptionsis nowPrisma.PollGetPayload<{ include: typeof pollInclude }>derived from a single sharedpollIncludeconstant — the hand-written interface and all sixas unknown as PollWithOptionscasts are gone, so schema drift is caught by the compiler.src/types/pollSettings.ts: onePollSettingsinterface (replacing three competing definitions) and agetSettings()helper applying the documented defaults (allowVoteChange: true,liveResults: true) in one place. Replaces 13 inlinepoll.settings as {...}casts across actions, jobs, and blocks. Behavior preserved.Dead code / dependencies
buildResultsDM,renderTextBar,renderResultsText, and thegetButtonEmojipass-through alias (grep-verified unreferenced)uuid/@types/uuid; movedprismaCLI to devDependencies; lockfile refreshedpollCreationSubmission.tswith the existing static importPOLL_TYPE_LABELS(previously defined 4×) centralized insrc/constants.tsCI
New
.github/workflows/ci.ymlon PRs and pushes tomain:npm ci→npx prisma generate→npx tsc --noEmit(dummyDATABASE_URLforprisma.config.ts).Docs
CLAUDE.md updated: removed the dead
buildResultsDMreference, documented thelist_results_/edit_scheduled_/repost_poll_/schedule_repost_action prefixes, and refreshed the Key Types section.Validation:
npx tsc --noEmitpasses with zero errors.https://claude.ai/code/session_01BHGzHCWjWcXS5XFG6GetiL
Generated by Claude Code