diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 03:58:14 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 03:58:14 +0200 |
| commit | 49a80c2f48531edc2a2719d77d3c5a8c111289dd (patch) | |
| tree | c09f4451049479b41c47221953ff4b62da3501f7 /app | |
| parent | 52cd07b6ff191efd25938b173b7eb14411fec3e4 (diff) | |
Convert the log's node zoom to participants, completing subtree histories
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/node_actions_controller.rb | 6 | ||||
| -rw-r--r-- | app/models/node.rb | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/app/controllers/node_actions_controller.rb b/app/controllers/node_actions_controller.rb index 6e467197..9b97b450 100644 --- a/app/controllers/node_actions_controller.rb +++ b/app/controllers/node_actions_controller.rb | |||
| @@ -6,7 +6,11 @@ class NodeActionsController < ApplicationController | |||
| 6 | 6 | ||
| 7 | def index | 7 | def index |
| 8 | @actions = NodeAction.order(:occurred_at => :desc, :id => :desc) | 8 | @actions = NodeAction.order(:occurred_at => :desc, :id => :desc) |
| 9 | @actions = @actions.where(:node_id => params[:node_id]) if params[:node_id].present? | 9 | if params[:node_id].present? |
| 10 | @actions = @actions.joins(:action_participants) | ||
| 11 | .where(:action_participants => { :subject_type => "Node", | ||
| 12 | :subject_id => params[:node_id] }) | ||
| 13 | end | ||
| 10 | @actions = @actions.where(:user_id => params[:user_id]) if params[:user_id].present? | 14 | @actions = @actions.where(:user_id => params[:user_id]) if params[:user_id].present? |
| 11 | @actions = @actions.includes(:node, :user) | 15 | @actions = @actions.includes(:node, :user) |
| 12 | .paginate(:page => params[:page], :per_page => 50) | 16 | .paginate(:page => params[:page], :per_page => 50) |
diff --git a/app/models/node.rb b/app/models/node.rb index e92fa1ea..7a93e799 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -4,7 +4,14 @@ class Node < ApplicationRecord | |||
| 4 | 4 | ||
| 5 | # Associations | 5 | # Associations |
| 6 | has_many :pages, -> { order("revision ASC") }, :dependent => :destroy | 6 | has_many :pages, -> { order("revision ASC") }, :dependent => :destroy |
| 7 | |||
| 8 | # Entries where this node is the primary subject (fast-path column). | ||
| 9 | # For a *complete* history -- including subtree trash/destroy entries | ||
| 10 | # recorded at an ancestor -- use participated_actions instead. | ||
| 7 | has_many :node_actions, :dependent => :nullify | 11 | has_many :node_actions, :dependent => :nullify |
| 12 | has_many :action_participations, :class_name => "ActionParticipant", :as => :subject | ||
| 13 | has_many :participated_actions, :through => :action_participations, :source => :node_action | ||
| 14 | |||
| 8 | belongs_to :head, :class_name => "Page", :foreign_key => :head_id, optional: true | 15 | belongs_to :head, :class_name => "Page", :foreign_key => :head_id, optional: true |
| 9 | belongs_to :draft, :class_name => "Page", :foreign_key => :draft_id, optional: true | 16 | belongs_to :draft, :class_name => "Page", :foreign_key => :draft_id, optional: true |
| 10 | # Autosave pages carry no node_id, so has_many :pages does not cover | 17 | # Autosave pages carry no node_id, so has_many :pages does not cover |
