diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-03 00:53:35 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-03 00:53:35 +0200 |
| commit | 751261c2ffdc90e93869192555ae0d5e4070ff79 (patch) | |
| tree | 5023240ca3a10653fe560a259d0e46e6c6a7240f /lib | |
| parent | f2f2b31832ec320889f2178e7e08838723961a14 (diff) | |
Display stale accounts in users#index
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tasks/users.rake | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake index ee5da7dc..56e5bb6a 100644 --- a/lib/tasks/users.rake +++ b/lib/tasks/users.rake | |||
| @@ -26,10 +26,13 @@ namespace :users do | |||
| 26 | desc "Seed last_login_at from whatever the database still remembers. " \ | 26 | desc "Seed last_login_at from whatever the database still remembers. " \ |
| 27 | "There is no login history, so the column is reconstructed once " \ | 27 | "There is no login history, so the column is reconstructed once " \ |
| 28 | "from the newest trace each account left: log entries, authorship, " \ | 28 | "from the newest trace each account left: log entries, authorship, " \ |
| 29 | "editing, tagging. Accounts with no trace fall back to their own " \ | 29 | "editing, tagging. An account with no trace is left nil, which the " \ |
| 30 | "created_at, which tells an ancient untraceable account apart from " \ | 30 | "roster renders as never signed in -- do not substitute created_at, " \ |
| 31 | "one made yesterday. Dry run unless WRITE=1; FORCE=1 is required " \ | 31 | "which is evidence that an account exists, not that anyone used it, " \ |
| 32 | "once any real login has been recorded." | 32 | "and shadows exactly the signal worth seeing. Dry run unless " \ |
| 33 | "WRITE=1. FORCE=1 is required once the column holds anything, and " \ | ||
| 34 | "re-running then overwrites real logins: an account that signs in " \ | ||
| 35 | "regularly but never edits leaves no trace and would be reset." | ||
| 33 | task :seed_last_login => :environment do | 36 | task :seed_last_login => :environment do |
| 34 | write = ENV["WRITE"] == "1" | 37 | write = ENV["WRITE"] == "1" |
| 35 | force = ENV["FORCE"] == "1" | 38 | force = ENV["FORCE"] == "1" |
| @@ -64,17 +67,10 @@ namespace :users do | |||
| 64 | users.each do |user| | 67 | users.each do |user| |
| 65 | clues = newest.transform_values { |by_id| by_id[user.id] }.compact | 68 | clues = newest.transform_values { |by_id| by_id[user.id] }.compact |
| 66 | source, date = clues.max_by { |_, at| at } | 69 | source, date = clues.max_by { |_, at| at } |
| 67 | source, date = "created", user.created_at if date.nil? | ||
| 68 | source, date = "floor", floor if date.nil? | ||
| 69 | |||
| 70 | if date.nil? | ||
| 71 | puts format("%-18s %-12s %-8s %s", user.login, "SKIPPED", "none", user.roles.join(",")) | ||
| 72 | next | ||
| 73 | end | ||
| 74 | 70 | ||
| 75 | user.update_columns(:last_login_at => date) if write | 71 | user.update_columns(:last_login_at => date) if write |
| 76 | puts format("%-18s %-12s %-8s %s", user.login, date.to_date, source, user.roles.join(",")) | 72 | puts format("%-18s %-12s %-8s %s", user.login, |
| 73 | date ? date.to_date : "never", source || "-", user.roles.join(",")) | ||
| 77 | end | 74 | end |
| 78 | end | 75 | end |
| 79 | |||
| 80 | end | 76 | end |
