From d9e95bdb6436768c738539df74a164c885887174 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 23 Jul 2026 03:28:55 +0200 Subject: Add action_participants, recording every node a trash/destroy touches --- lib/tasks/node_actions.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/tasks/node_actions.rake b/lib/tasks/node_actions.rake index fdd286c1..c378db24 100644 --- a/lib/tasks/node_actions.rake +++ b/lib/tasks/node_actions.rake @@ -58,4 +58,18 @@ namespace :node_actions do puts "Created #{created} inferred entries" end + + desc "Backfill action_participants for existing single-subject entries. " \ + "Idempotent: entries that already have a participant row are skipped. " \ + "Multi-node trash/destroy entries predating this feature are NOT " \ + "reconstructable (only a count was ever stored) and are left as-is." + task :backfill_participants => :environment do + scope = NodeAction.where.missing(:action_participants).where.not(:node_id => nil) + created = 0 + scope.find_each do |action| + action.action_participants.create!(:subject => action.node) + created += 1 + end + puts "Created #{created} participant rows" + end end -- cgit v1.3