Surface pending review queues on admin home#1548
Conversation
Admins had to visit each ideas index to discover work waiting for them. This adds a dashboard banner that counts user-submitted ideas not yet promoted into their published counterparts, so the review backlog is visible at a glance on login. Closes #1524 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| class PendingReviewSummary | ||
| Queue = Data.define(:label, :count, :model) | ||
|
|
||
| QUEUE_DEFINITIONS = [ |
There was a problem hiding this comment.
Adding a new admin review queue is intentionally a one-line change here — append { model: SomeIdea, label: "..." } and it shows up on the dashboard automatically, provided the model defines a pending_review scope.
| has_many :stories | ||
|
|
||
| # Ideas awaiting admin review have not yet been promoted into a published Story. | ||
| scope :pending_review, -> { where.missing(:stories) } |
There was a problem hiding this comment.
"Pending review" is derived from the existing promotion relationship rather than a new status column: an idea is pending until it has been promoted into a Story (the same signal the index's "Promoted to Story" column already uses). Keeps this consistent with how the rest of the app reasons about idea state and avoids a migration.
| <h1 class="text-2xl font-semibold text-gray-900">Admin home</h1> | ||
| </div> | ||
|
|
||
| <%= render "review_notifications", review_summary: @review_summary %> |
There was a problem hiding this comment.
Banner renders above the existing cards so the backlog is the first thing an admin sees on login. The partial no-ops when nothing is pending, so the dashboard is unchanged when caught up.
There was a problem hiding this comment.
Pull request overview
Surfaces a consolidated “pending review” summary on the admin dashboard (/admin) so admins can see (and navigate to) unpromoted idea queues at a glance.
Changes:
- Added
pending_reviewscopes to idea models based on whether a promoted counterpart exists. - Introduced
PendingReviewSummaryservice to aggregate queue labels + counts for the dashboard. - Rendered a new admin-home notification banner and added request/service/model specs to cover the behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
app/models/story_idea.rb |
Adds pending_review scope using where.missing(:stories) to identify unpromoted story ideas. |
app/models/workshop_variation_idea.rb |
Adds pending_review scope using where.missing(:workshop_variations) to identify unpromoted variation ideas. |
app/models/workshop_idea.rb |
Adds pending_review scope using where.missing(:workshops) to identify unpromoted workshop ideas. |
app/services/pending_review_summary.rb |
New service that enumerates queue definitions and computes per-queue + total pending counts. |
app/controllers/admin/home_controller.rb |
Instantiates PendingReviewSummary for use by the admin home view. |
app/views/admin/home/index.html.erb |
Renders the new review notification partial on the admin dashboard. |
app/views/admin/home/_review_notifications.html.erb |
New banner partial showing total pending count and per-queue links. |
spec/services/pending_review_summary_spec.rb |
Adds service specs for queue counts, filtering pending queues, and totals. |
spec/requests/admin/home_spec.rb |
Adds request specs asserting the banner appears/omits based on pending items. |
spec/models/story_idea_spec.rb |
Adds model scope specs for StoryIdea.pending_review. |
spec/models/workshop_variation_idea_spec.rb |
Adds model scope specs for WorkshopVariationIdea.pending_review. |
spec/models/workshop_idea_spec.rb |
Adds model scope specs for WorkshopIdea.pending_review. |
AGENTS.md |
Updates service count and documents PendingReviewSummary. |
| <li> | ||
| <%= link_to polymorphic_path(queue.model), | ||
| class: "inline-flex items-center gap-2 font-medium text-yellow-900 hover:underline" do %> | ||
| <span class="inline-flex items-center justify-center min-w-6 h-6 px-2 rounded-full bg-yellow-200 text-yellow-900 text-sm font-bold"> |
Closes #1524
What is the goal of this PR and why is this important?
/admin), there was no way to see what's waiting for them without visiting each ideas index individually.How did you approach the change?
pending_reviewscope to each idea model — an idea is "pending" until it has been promoted:StoryIdea— no associatedStory(where.missing(:stories))WorkshopVariationIdea— no associatedWorkshopVariationWorkshopIdea— no associatedWorkshopPendingReviewSummaryservice that gathers each queue's label, pending count, and originating model, pluspending_queues/total_count/any?helpers.Admin::HomeController#indexbuilds the summary; a new_review_notificationspartial renders a dismissible-style yellow banner at the top of the dashboard with a count badge per queue, each linking to the relevant index. The banner is omitted entirely when nothing is pending.QUEUE_DEFINITIONS.UI Testing Checklist
/adminwith correct counts and links.Anything else to add?
PendingReviewSummaryservice spec, and request specs asserting the banner appears (and is omitted when nothing is pending). All passing.rounded-xl shadowcard styling for visual consistency.🤖 Generated with Claude Code