Add pending completion accordion to weekly view #194
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/pending-completion-accordion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
pending_completionfeature flag — super admin toggles from Platform panelChanges
app/controllers/weeks_controller.rb-- queries incomplete items from past days when flag is enabledapp/views/weeks/index.html.erb-- accordion UI with<details>element, info tooltip, pending item listapp/javascript/controllers/tooltip_controller.js-- Stimulus controller for info icon toggleapp/assets/stylesheets/application.css-- PendingCompletion component styles (accordion, info bar, item list)lib/tasks/feature_flags.rake-- registerspending_completionflag (default OFF)spec/requests/weeks_spec.rb-- 4 specs covering pending items, completed exclusion, flag gating, future week exclusionTest Plan
FeatureFlag.enable(:pending_completion)Review Checklist
pending_completiontofeature_flags:syncrake task and gated withfeature_enabled?(:pending_completion)in controller and viewRelated Notes
landscaping-assistant— project this affectsPR #194 Review
DOMAIN REVIEW
Tech stack: Ruby on Rails (controllers, ERB views, ActiveRecord), Stimulus.js, vanilla CSS with design tokens. Reviewing for Rails correctness, Stimulus patterns, CSS consistency, and test coverage.
Controller query logic (
weeks_controller.rb)The cutoff calculation is correct and well-structured:
This correctly handles: (1) past weeks where everything is already past -- cutoff is
@end_date; (2) the current week -- cutoff is yesterday; (3) future weeks -- cutoff is less than@start_date, soWorkQueueItem.noneis returned. Good edge case handling.The
.includes(:property)prevents N+1 queries when the view iterates@pending_itemsand accessesitem.property.client_nameanditem.property.address_line. Correct.Feature flag gating is applied in both the controller (query is skipped entirely when flag is off) and the view (
feature_enabled?(:pending_completion) && @pending_items.present?). Double-gating is correct -- the view guard prevents rendering even if@pending_itemsleaks through somehow.Rake task follows the existing pattern. The flag description omits an issue number reference though -- see Nits.
View safety (XSS): ERB
<%= ... %>auto-escapes by default in Rails.item.property.client_name,item.property.address_line, anditem.work_date.strftime(...)are all safe. Noraworhtml_safeusage. Good.CSS: All new styles use existing design tokens (
--spacing-*,--color-*,--radius). No magic numbers for spacing or colors. The component comment header follows the existing convention (component name + view reference). Thefont-sizevalues (0.75rem, 0.8rem, 0.95rem) match sizes used elsewhere in the stylesheet. Clean.BLOCKERS
1. Stimulus tooltip controller scope bug (BLOCKER)
In
app/views/weeks/index.html.erb, thedata-controller="tooltip"is placed on the<button>element, but the targetdata-tooltip-target="content"is on a sibling<span>:Stimulus targets must be descendants of the controller element -- siblings are outside the controller's DOM scope. When the button is clicked,
this.contentTargetwill throw aMissing target element "tooltip.content"error. The info icon will not work.Fix: Move
data-controller="tooltip"up to the parent<div class="pending-info-bar">, and change the action toclick->tooltip#toggleon the button without the controller declaration:2.
@pending_items.sizetriggers a second query (performance concern, borderline BLOCKER)In the view:
<span class="pending-count"><%= @pending_items.size %></span>@pending_itemsis an ActiveRecord::Relation. Calling.sizeon it will issue aSELECT COUNT(*)query if the relation has not yet been loaded. Then the.eachloop below loads all records. This means two queries instead of one.Use
.lengthinstead of.size-- this forces eager loading so the subsequent.eachreuses the already-loaded collection. Or call.loadon the relation in the controller. This is a minor performance issue but worth fixing while you are in the code.NITS
Feature flag description missing issue reference. The existing flags reference their issue numbers (
"Stripe payment integration (#125)","Client request UI (#123)"). The new flag says"Pending completion accordion on weekly view"without referencing #193. Add(#193)for traceability.Test does not cover the "current week with some past days" edge case. The tests use
past_monday(a fully past week) andfuture_monday(a fully future week). The most important real-world scenario -- the current week where today is mid-week and earlier days have incomplete items -- is not tested. This is the primary use case and should have a spec. Not a blocker since the query logic is sound, but a gap.Test does not verify the tooltip info text content. No spec checks that the info explanation text renders. Low priority since it is static text, but a quick
include("haven't been marked complete")assertion would catch accidental deletion..present?on the relation in the view (@pending_items.present?) issues a query to check existence. Since you are already going to iterate, consider.any?which is consistent with how@assigned.any?and@unassigned.any?are used elsewhere in the same view. (.any?on an unloaded relation also issues a query, but if you apply the.loadfix from Blocker #2, both.present?and.any?become free.)Accordion starts collapsed. This is intentional UX (the
<details>element is closed by default), but consider whether pending items should be open by default to increase visibility -- these are items that need attention. This is a UX decision, not a code issue.SOP COMPLIANCE
feature/pending-completion-accordion, not193-pending-completion-accordion. Convention requires{issue-number}-{kebab-case-purpose}.Closes #193is present.PROCESS OBSERVATIONS
VERDICT: NOT APPROVED
Two issues must be resolved before merge:
data-controllermust be moved to the parent<div>so the target<span>is within scope.{issue-number}-{kebab-case-purpose}convention. This should be193-pending-completion-accordionper SOP.PR #194 Re-Review
Re-review after fix commit
f3d27afaddressing Stimulus scoping blocker from initial review.BLOCKER RESOLUTION
Blocker 1: Stimulus controller scope bug -- RESOLVED
The fix correctly moves
data-controller="tooltip"from the<button>up to the parent<div class="pending-info-bar">. The resulting DOM structure is:Both the action element (button) and the target element (span) are now descendants of the controller element. Stimulus target resolution will work correctly.
Blocker 2: Branch naming convention -- ACKNOWLEDGED
Branch is
feature/pending-completion-accordioninstead of193-pending-completion-accordion. Acknowledged in prior review as not worth a new PR cycle. No change expected.DOMAIN REVIEW
Ruby on Rails / Stimulus / CSS -- no new issues found on re-review. The six files in this PR remain clean:
.includes(:property)to avoid N+1, scoped correctly with cutoff dateSOP COMPLIANCE
VERDICT: APPROVED