Skip to content

Surface pending review queues on admin home#1548

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/admin-pending-review-notifications
Draft

Surface pending review queues on admin home#1548
maebeale wants to merge 1 commit into
mainfrom
maebeale/admin-pending-review-notifications

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Jun 5, 2026

Closes #1524

What is the goal of this PR and why is this important?

  • When an admin logs in and lands on the admin home (/admin), there was no way to see what's waiting for them without visiting each ideas index individually.
  • This surfaces a single notification banner summarizing all the admin review queues — user-submitted ideas that haven't yet been promoted into their published counterparts.
  • Makes the review backlog visible at a glance, which is the core stakeholder ask in the issue.

How did you approach the change?

  • Added a pending_review scope to each idea model — an idea is "pending" until it has been promoted:
    • StoryIdea — no associated Story (where.missing(:stories))
    • WorkshopVariationIdea — no associated WorkshopVariation
    • WorkshopIdea — no associated Workshop
  • Added a PendingReviewSummary service that gathers each queue's label, pending count, and originating model, plus pending_queues / total_count / any? helpers.
  • Admin::HomeController#index builds the summary; a new _review_notifications partial 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.
  • Extensible by design: adding a new review queue is a one-line addition to QUEUE_DEFINITIONS.

UI Testing Checklist

  • As an admin with pending story / workshop variation / workshop ideas, the banner shows on /admin with correct counts and links.
  • As an admin with everything promoted, the banner does not render.
  • Count badges link to the corresponding ideas index.

Anything else to add?

  • Tests: model scope specs, a PendingReviewSummary service spec, and request specs asserting the banner appears (and is omitted when nothing is pending). All passing.
  • Banner uses the existing flash/notification yellow palette and the dashboard's rounded-xl shadow card styling for visual consistency.
  • Counts link to each full index (which already shows promotion status); a future enhancement could add a "pending only" filter to those indexes.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 5, 2026 00:41
class PendingReviewSummary
Queue = Data.define(:label, :count, :model)

QUEUE_DEFINITIONS = [
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread app/models/story_idea.rb
has_many :stories

# Ideas awaiting admin review have not yet been promoted into a published Story.
scope :pending_review, -> { where.missing(:stories) }
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

"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 %>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

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

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_review scopes to idea models based on whether a promoted counterpart exists.
  • Introduced PendingReviewSummary service 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">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin dashboard: notification on login of pending review tasks

2 participants