Day detail page: "Previously [Day]s" accordion with historical frequency #235

Closed
opened 2026-06-16 03:32:05 +00:00 by ldraney · 1 comment
Owner

Type

Feature

Lineage

Decomposed from #233 (2 of 4). Depends on #234 (day detail page must exist).

Repo

ldraney/landscaping-assistant

User Story

As a crew lead or admin
I want to see which properties have historically been assigned on a given weekday
So that I can quickly plan the day by referencing past patterns

Context

The day detail page (created in #234) needs a "Previously Tuesdays" accordion that shows every property ever assigned on that weekday, sorted by frequency (most common first). This uses the same DOW extraction pattern as the existing compute_unqueued_this_week method in WorkQueueItemsController (lines 231-245), but returns ALL historical properties for the weekday rather than filtering to unqueued ones.

Properties already queued for the current date should be visually distinguished (e.g., muted or with a "queued" badge) so the user knows they're already planned.

File Targets

Files to create:

  • app/views/days/_previously_section.html.erb -- accordion partial using existing <details> + accordion Stimulus controller pattern

Files to modify:

  • app/controllers/days_controller.rb -- add @previously query: historical DOW frequency for properties assigned on this weekday, sorted descending by count
  • app/views/days/show.html.erb -- render the _previously_section partial

Files NOT to touch:

  • app/controllers/work_queue_items_controller.rb -- Today tab unchanged
  • app/javascript/controllers/accordion_controller.js -- reuse as-is

Feature Flag

Flag: none
This is additive content on the new day detail page.

Acceptance Criteria

  • "Previously Tuesdays" accordion appears on /days/2026-06-17 (day name matches the date's weekday)
  • Lists all properties that have ever had a WorkQueueItem on any Tuesday, sorted by frequency descending
  • Properties already queued for the viewed date show a "queued" badge or muted style
  • Accordion state persists via localStorage (using existing accordion controller)
  • Empty state shows "No historical data for Tuesdays" when no properties have ever been assigned

Test Expectations

  • Request spec: "Previously Tuesdays" heading appears in response for a Tuesday date
  • Request spec: properties with historical Tuesday assignments appear in the section
  • Request spec: properties with more Tuesday assignments appear before those with fewer
  • Request spec: empty state renders when no historical data exists
  • Run command: bundle exec rspec spec/requests/days_spec.rb

Constraints

  • Reuse accordion_controller.js with data-accordion-key-value="previously-{wday}"
  • Historical query: WorkQueueItem.where("EXTRACT(DOW FROM work_date) = ?", date.wday).group(:property_id).order("count_id DESC").count(:id)
  • Include only active properties in the results
  • Keep query efficient -- single query with group/count, no N+1

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-landscaping-assistant
  • Parent: #233 (decomposed)
  • Depends on: #234 (day detail page)
### Type Feature ### Lineage Decomposed from #233 (2 of 4). Depends on #234 (day detail page must exist). ### Repo `ldraney/landscaping-assistant` ### User Story As a crew lead or admin I want to see which properties have historically been assigned on a given weekday So that I can quickly plan the day by referencing past patterns ### Context The day detail page (created in #234) needs a "Previously Tuesdays" accordion that shows every property ever assigned on that weekday, sorted by frequency (most common first). This uses the same DOW extraction pattern as the existing `compute_unqueued_this_week` method in `WorkQueueItemsController` (lines 231-245), but returns ALL historical properties for the weekday rather than filtering to unqueued ones. Properties already queued for the current date should be visually distinguished (e.g., muted or with a "queued" badge) so the user knows they're already planned. ### File Targets Files to create: - `app/views/days/_previously_section.html.erb` -- accordion partial using existing `<details>` + `accordion` Stimulus controller pattern Files to modify: - `app/controllers/days_controller.rb` -- add `@previously` query: historical DOW frequency for properties assigned on this weekday, sorted descending by count - `app/views/days/show.html.erb` -- render the `_previously_section` partial Files NOT to touch: - `app/controllers/work_queue_items_controller.rb` -- Today tab unchanged - `app/javascript/controllers/accordion_controller.js` -- reuse as-is ### Feature Flag Flag: none This is additive content on the new day detail page. ### Acceptance Criteria - [ ] "Previously Tuesdays" accordion appears on `/days/2026-06-17` (day name matches the date's weekday) - [ ] Lists all properties that have ever had a `WorkQueueItem` on any Tuesday, sorted by frequency descending - [ ] Properties already queued for the viewed date show a "queued" badge or muted style - [ ] Accordion state persists via localStorage (using existing accordion controller) - [ ] Empty state shows "No historical data for Tuesdays" when no properties have ever been assigned ### Test Expectations - [ ] Request spec: "Previously Tuesdays" heading appears in response for a Tuesday date - [ ] Request spec: properties with historical Tuesday assignments appear in the section - [ ] Request spec: properties with more Tuesday assignments appear before those with fewer - [ ] Request spec: empty state renders when no historical data exists - [ ] Run command: `bundle exec rspec spec/requests/days_spec.rb` ### Constraints - Reuse `accordion_controller.js` with `data-accordion-key-value="previously-{wday}"` - Historical query: `WorkQueueItem.where("EXTRACT(DOW FROM work_date) = ?", date.wday).group(:property_id).order("count_id DESC").count(:id)` - Include only active properties in the results - Keep query efficient -- single query with group/count, no N+1 ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-landscaping-assistant` - Parent: #233 (decomposed) - Depends on: #234 (day detail page)
Author
Owner

Scope Review: READY

Review note: review-1473-2026-06-15

Scope is solid. All file targets verified against codebase: DOW extraction pattern at lines 231-245 confirmed, accordion controller exists with keyValue pattern, Property.active scope verified. Template is complete with all required sections for Feature type. Traceability triangle intact (story:weekly-tracking found in project page, Forgejo issue open).

Dependency on #234 (day detail page controller/route/view) is properly documented and must be completed first -- currently in backlog as board item #1472.

One non-blocking platform-wide gap: no arch-rails-app note exists in pal-e-docs.

## Scope Review: READY Review note: `review-1473-2026-06-15` Scope is solid. All file targets verified against codebase: DOW extraction pattern at lines 231-245 confirmed, accordion controller exists with keyValue pattern, Property.active scope verified. Template is complete with all required sections for Feature type. Traceability triangle intact (story:weekly-tracking found in project page, Forgejo issue open). Dependency on #234 (day detail page controller/route/view) is properly documented and must be completed first -- currently in backlog as board item #1472. One non-blocking platform-wide gap: no `arch-rails-app` note exists in pal-e-docs.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/landscaping-assistant#235
No description provided.