diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-27 02:53:21 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-27 02:53:21 +0200 |
| commit | 180b5feba092db1339f7bb3217e91f0b22239bc5 (patch) | |
| tree | ed2912eb568639d027e2d54bc4f28c7a9406f7e0 /app/models | |
| parent | 102c33264fd1463cd88aa8245413e7b331dd9632 (diff) | |
Surface held locks in the dashboard's work-in-progress widget
A lock with no draft or autosave behind it was invisible to
everyone including its holder, until the next editor collided
with it. work_in_progress now admits those nodes, and the
widget names the holder rather than the last editor on any
locked row.
Also flips the ordering to stalest-first, so a backlog reads as a queue
rather than a feed, and gives the heading a real total: the count came
from the already-limited relation and could never exceed five.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/node.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 02502f6c..1e61f9fe 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -593,12 +593,15 @@ class Node < ApplicationRecord | |||
| 593 | .distinct | 593 | .distinct |
| 594 | end | 594 | end |
| 595 | 595 | ||
| 596 | def self.drafts_and_autosaves(current_user_id: nil) | 596 | # Nodes carrying unfinished work: a draft, an autosave, or a lock with |
| 597 | scope = where("draft_id IS NOT NULL OR autosave_id IS NOT NULL").not_in_trash | 597 | # neither behind it |
| 598 | return scope.order("updated_at DESC") unless current_user_id | 598 | def self.work_in_progress(current_user_id: nil) |
| 599 | scope = where("draft_id IS NOT NULL OR autosave_id IS NOT NULL OR locking_user_id IS NOT NULL") | ||
| 600 | .not_in_trash | ||
| 601 | return scope.order("nodes.updated_at ASC") unless current_user_id | ||
| 599 | 602 | ||
| 600 | scope.order( | 603 | scope.order( |
| 601 | Arel.sql(sanitize_sql_array(["CASE WHEN locking_user_id = ? THEN 0 ELSE 1 END, updated_at DESC", current_user_id])) | 604 | Arel.sql(sanitize_sql_array(["CASE WHEN locking_user_id = ? THEN 0 ELSE 1 END, nodes.updated_at ASC", current_user_id])) |
| 602 | ) | 605 | ) |
| 603 | end | 606 | end |
| 604 | 607 | ||
