Add last-week same-day queue section to Today tab #102
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "98-show-last-week-s-same-day-queue-on-the-t"
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
Adds a "Last [weekday]" section to the Today tab that shows properties queued on the same weekday 7 days ago, with a one-tap re-queue button to add them to today's queue.
Changes
app/controllers/work_queue_items_controller.rb-- Query last-week items inindex; look up last-week item indestroyfor Turbo Stream syncapp/views/work_queue_items/index.html.erb-- Render the last-week section between the queue list and the Recent section (only when items exist)app/views/work_queue_items/_last_week_item.html.erb-- New partial for each last-week row with re-queue button or "Queued" badgeapp/views/work_queue_items/create.turbo_stream.erb-- Replace last-week row on re-queue to swap button for badgeapp/views/work_queue_items/destroy.turbo_stream.erb-- Restore re-queue button on last-week row when item removed from todayapp/assets/stylesheets/application.css-- LastWeekSection and btn-requeue styles following existing design tokensspec/requests/work_queue_items_spec.rb-- 5 new specs covering section rendering, absence, queued state, date param, and turbo stream syncTest Plan
Review Checklist
createaction (POST to work_queue_items_path)Related Notes
None.
Related
Closes #98
QA Review -- PR #102
Scope Check
PR implements Forgejo #98: "Last week" section on the Today tab showing same-weekday items from 7 days ago with a re-queue button. All spec items addressed.
Findings
Controller -- Clean.
@last_week_itemsuses.includes(:property)to avoid N+1.destroyaction correctly looks up the last-week item for Turbo Stream sync.Partial --
_last_week_item.html.erbreceivesqueued_property_idsanddateas explicit locals, consistent with_property_item.html.erbpattern. Re-queue button POSTs to the existingcreateaction -- good reuse, no new endpoints.Turbo Streams --
create.turbo_stream.erbalways emits areplacetargetinglast_week_<property_id>. When the element is absent (item queued from picker, not from last-week section), Turbo silently ignores the no-op replace. Acceptable.destroy.turbo_stream.erbcorrectly guards withif @last_week_itemto avoid rendering the partial when no last-week row exists.Note on
create.turbo_stream.erb: The@itempassed to_last_week_item.html.erbis the newly-created today item, not the original last-week WorkQueueItem. This works because the partial only usesitem.property_idanditem.property(same property either way), but it is slightly misleading -- theitemlocal is a today-dated record being rendered in a "last week" row. No functional bug, just a semantic mismatch in the variable. Not blocking.CSS -- Follows existing design tokens and component patterns. No Tailwind.
btn-requeuemirrorsbtn-add/btn-icondimensions and transitions. Font sizes slightly smaller than other list items (0.9rem / 0.75rem vs 0.95rem / 0.8rem for queue-item and property-item) -- intentional to visually de-emphasize the historical section, which reads well.View -- Section heading "Last [weekday]" is clear. Section conditionally hidden with
if @last_week_items.any?-- no empty state noise.Tests -- 5 new specs covering: section present, section absent, queued badge state, date param, and turbo stream re-queue. Full suite green (93/93). Good coverage.
VERDICT: APPROVE
PR #102 Review
DOMAIN REVIEW
Tech stack: Ruby on Rails 8, Turbo Streams, vanilla CSS with design tokens, RSpec request specs.
Controller (
work_queue_items_controller.rb)indexaction adds@last_week_itemswith.includes(:property)-- correct eager loading, no N+1.destroyaction adds@last_week_item = WorkQueueItem.find_by(...)-- appropriate use offind_by(returns nil when no last-week item exists), and the turbo stream correctly guards withif @last_week_item.@date - 7.dayspattern is used consistently in bothindexanddestroy. No hardcoded date math drift.Turbo Stream sync (
create.turbo_stream.erb)turbo_stream.replace "last_week_#{@item.property_id}"targets a DOM id that only exists when a last-week item is rendered. When no such DOM element exists (property was not in last week's queue), Turbo Streamreplaceis a silent no-op. This is safe and intentional.item: @itemwhere@itemis the today queue item, not the last-week item. This works because the partial only readsitem.property_idanditem.property.*(which are identical for the same property), plusqueued_property_ids(which now correctly includes this property). Semantically imprecise but functionally correct.Turbo Stream sync (
destroy.turbo_stream.erb)if @last_week_item, and passes the actual last-week item to the partial. The@queued_property_idsis recomputed after destroy, so the re-queue button will correctly reappear.Partial (
_last_week_item.html.erb)_property_item.html.erbclosely: same address display logic, same "No address yet" fallback, samequeued-badgeclass reuse.button_togenerates a POST form with CSRF token automatically -- secure by default.date: dateparameter ensures re-queued items go to the correct date, not just today.CSS (
application.css)--spacing-sm,--color-accent, etc.) -- no magic numbers..btn-requeuedimensions (2.75rem x 2.75rem) match the existing.btn-iconpattern exactly. This is near-duplicate CSS (see nits).Specs (
spec/requests/work_queue_items_spec.rb)last_week_prefix appears in the response body.Missing test coverage (non-blocking): No spec for the
destroyturbo stream restoring the re-queue button on the last-week row. The create path is tested but the inverse (removing from queue restores the button) is not. This is the only untested Turbo Stream path.BLOCKERS
None. The PR has test coverage for new functionality, no unvalidated user input (all DB queries use parameterized ActiveRecord methods), no secrets or credentials, and no duplicated auth/security logic.
NITS
Near-duplicate CSS for
.btn-requeue: The.btn-requeuestyles are almost identical to.btn-icon(same dimensions, border-radius, cursor, background, transition). Consider extending.btn-iconand adding only the color override, e.g.,.btn-icon.btn-requeue { color: var(--color-accent); }. This would reduce ~15 lines of CSS and keep button styles from diverging.Semantic item mismatch in
create.turbo_stream.erb: The partial_last_week_itemis rendered withitem: @itemwhere@itemis the today-queue item. It works because only property data is read, but a future change to the partial that usesitem.work_dateoritem.positionwould silently produce wrong data. A comment explaining this would help.Missing destroy turbo stream spec: Adding a spec that creates a last-week item, queues the property for today, then DELETEs the today item and asserts the turbo stream response includes
last_week_would complete the round-trip coverage.Section heading could use the target date, not re-derive:
index.html.erbcomputes(@date - 7.days).strftime("%A")-- this repeats the 7-day offset already computed in the controller. Consider passing the weekday name as an instance variable from the controller to reduce logic in the view.SOP COMPLIANCE
98-show-last-week-s-same-day-queue-on-the-t(follows{issue-number}-{kebab-case-purpose}convention)PROCESS OBSERVATIONS
[property_id, work_date]prevents double-queue issues.VERDICT: APPROVED