Ruby 4.0.9, Rails 8.1 defaults, newest gems; admin About page

- Ruby 3.2.3 (end of life) -> 4.0.9 in the Docker image and .ruby-version
- config.load_defaults 8.1
- All gems at their newest compatible versions, including json 3.1,
  roo 4.0, rubyzip 3.7 and solid_cable 4.1
- Admin -> About: running revision and build time, uptime, Ruby/Rails/
  SQLite and key gem versions, which features are configured (never
  secret values), storage and database sizes, background job health,
  record counts. The image takes APP_REVISION and APP_BUILT_AT build args.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 08:56:14 -05:00
1 parent ac4da93aaf
commit 2b0a2f1949
13 files changed
+295 -50

No files matched your search

@@ -0,0 +1,7 @@
class Admin::AboutController < ApplicationController
before_action :require_admin!
def show
@info = SystemInfo.new
end
end
+101
View File
@@ -0,0 +1,101 @@
# What the admin About page shows: versions, configuration (never secrets)
# and a health summary of the database, file storage and background jobs.
class SystemInfo
KEY_GEMS = %w[
puma thruster propshaft importmap-rails turbo-rails stimulus-rails tailwindcss-rails tailwindcss-ruby
solid_queue solid_cache solid_cable sqlite3 chartkick commonmarker anthropic
omniauth omniauth_openid_connect rubyzip roo pdf-reader bcrypt
].freeze
DATABASES = { "Main" => :primary, "Cache" => :cache, "Jobs" => :queue, "Cable" => :cable }.freeze
# Set by the Docker build (see Dockerfile); in development, read from git.
def revision
@revision ||= ENV["APP_REVISION"].presence ||
(Rails.root.join(".git").exist? && `git -C #{Rails.root} rev-parse --short HEAD 2>/dev/null`.strip.presence) ||
"unknown"
end
def built_at
Time.zone.parse(ENV["APP_BUILT_AT"].to_s) if ENV["APP_BUILT_AT"].present?
rescue ArgumentError
nil
end
def booted_at = Rails.application.config.x.booted_at
def runtime
{
"Ruby" => "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})",
"YJIT" => defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? ? "on" : "off",
"Rails" => Rails.version,
"SQLite" => SQLite3::SQLITE_VERSION,
"Bundler" => Bundler::VERSION,
"Environment" => Rails.env,
"Time zone" => Time.zone.name
}
end
def key_gems
KEY_GEMS.filter_map { |name| (spec = specs[name]) && [ name, spec.version.to_s ] }
end
def all_gems = specs.values.sort_by(&:name).map { [ _1.name, _1.version.to_s ] }
# Configured or not; secret values are never read out.
def features
{
"Single sign-on" => Sso.enabled? ? "#{Sso.label}#{', password sign-in off' unless Sso.password_login?}" : "not configured",
"AI logbook transcription" => ENV["ANTHROPIC_API_KEY"].present? ? "on (#{LogbookTranscriber::MODEL})" : "no API key",
"Password-reset email" => ENV["SMTP_ADDRESS"].present? ? "SMTP" : "not configured",
"HTTPS enforced" => Rails.application.config.force_ssl ? "yes" : "no",
"File storage" => ActiveStorage::Blob.service.class.name.demodulize.delete_suffix("Service")
}
end
def databases
DATABASES.filter_map do |label, name|
config = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: name.to_s)
next unless config
path = Rails.root.join(config.database.to_s)
[ label, path.exist? ? Dir["#{path}*"].sum { File.size(_1) } : nil ]
end
end
def record_counts
{ "Users" => User.count, "Aircraft" => Aircraft.count, "Documents" => Document.count,
"Logbook entries" => LogbookEntry.count, "Flights" => FlightLog.count, "Squawks" => Squawk.count }
end
# Bytes saved by storing identical files once, estimated from checksums.
def storage
blobs = ActiveStorage::Blob
total = blobs.sum(:byte_size)
unique = blobs.group(:checksum).maximum(:byte_size).values.sum
{ files: blobs.count, bytes: total, shared_bytes: total - unique, free_bytes: free_disk_bytes }
end
def jobs
return unless defined?(SolidQueue) && SolidQueue::Job.table_exists?
{
workers: SolidQueue::Process.where(last_heartbeat_at: 5.minutes.ago..).count,
ready: SolidQueue::ReadyExecution.count,
scheduled: SolidQueue::ScheduledExecution.count,
failed: SolidQueue::FailedExecution.count
}
rescue ActiveRecord::ActiveRecordError
nil
end
private
def specs = Gem.loaded_specs
def free_disk_bytes
root = ActiveStorage::Blob.service.try(:root) or return
line = IO.popen([ "df", "-Pk", root.to_s ], err: File::NULL, &:read).lines.last
line.split[3].to_i * 1024 if line
rescue SystemCallError
nil
end
end
+8
View File
@@ -0,0 +1,8 @@
<dl class="divide-y divide-slate-100 text-sm">
<% pairs.each do |label, value| %>
<div class="flex items-baseline justify-between gap-4 px-4 py-2">
<dt class="text-slate-500"><%= label %></dt>
<dd class="min-w-0 break-words text-right font-medium text-slate-800"><%= value.presence || "—" %></dd>
</div>
<% end %>
</dl>
+75
View File
@@ -0,0 +1,75 @@
<% content_for :title, "About" %>
<% info = @info %>
<h1 class="mb-1 text-2xl font-bold">About</h1>
<p class="mb-5 text-sm text-slate-500">Simple Aircraft Manager: what's running, and how it's set up.</p>
<section class="card card-body mb-5">
<div class="flex flex-wrap items-end justify-between gap-4">
<div>
<p class="text-xs uppercase tracking-wide text-slate-500">Version</p>
<p class="font-mono text-2xl font-semibold" data-revision><%= info.revision %></p>
</div>
<dl class="grid grid-cols-2 gap-x-6 gap-y-1 text-sm sm:grid-cols-3">
<div><dt class="text-slate-500">Built</dt><dd class="font-medium"><%= info.built_at ? l(info.built_at.in_time_zone, format: :short) : "—" %></dd></div>
<div><dt class="text-slate-500">Started</dt><dd class="font-medium"><%= l(info.booted_at.in_time_zone, format: :short) %></dd></div>
<div><dt class="text-slate-500">Uptime</dt><dd class="font-medium"><%= distance_of_time_in_words(info.booted_at, Time.current) %></dd></div>
</dl>
</div>
</section>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card">
<div class="card-header"><h2 class="card-title">Runtime</h2></div>
<%= render "pairs", pairs: info.runtime %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Features</h2></div>
<%= render "pairs", pairs: info.features %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Key components</h2></div>
<%= render "pairs", pairs: info.key_gems %>
</section>
<div class="space-y-5">
<section class="card">
<div class="card-header"><h2 class="card-title">Storage</h2></div>
<% s = info.storage %>
<%= render "pairs", pairs: [
[ "Uploaded files", "#{number_with_delimiter(s[:files])} (#{number_to_human_size(s[:bytes])})" ],
[ "Saved by storing duplicates once", number_to_human_size(s[:shared_bytes]) ],
[ "Free disk space", s[:free_bytes] && number_to_human_size(s[:free_bytes]) ]
] + info.databases.map { |label, bytes| [ "#{label} database", bytes && number_to_human_size(bytes) ] } %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Background jobs</h2></div>
<% if (j = info.jobs) %>
<%= render "pairs", pairs: [
[ "Workers running", j[:workers].zero? ? tag.span("none", class: "badge-red") : j[:workers] ],
[ "Waiting", j[:ready] ], [ "Scheduled", j[:scheduled] ],
[ "Failed", j[:failed].positive? ? tag.span(j[:failed], class: "badge-orange") : 0 ]
] %>
<% else %>
<%= empty_state "Job queue not available." %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Records</h2></div>
<%= render "pairs", pairs: info.record_counts.transform_values { number_with_delimiter(_1) } %>
</section>
</div>
</div>
<details class="card mt-5">
<summary class="card-header cursor-pointer"><span class="card-title">All gems (<%= info.all_gems.size %>)</span></summary>
<div class="grid gap-x-6 px-4 py-3 font-mono text-xs sm:grid-cols-2 lg:grid-cols-3">
<% info.all_gems.each do |name, version| %>
<div class="flex justify-between gap-2 py-0.5"><span class="truncate"><%= name %></span><span class="text-slate-500"><%= version %></span></div>
<% end %>
</div>
</details>
+2 -2
View File
@@ -37,7 +37,7 @@
<%= link_to "Profile", edit_profile_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<% if current_user.admin? %>
<p class="border-t border-slate-100 px-4 pt-2 pb-1 text-xs font-semibold text-slate-500">Admin</p>
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ] ].each do |label, path| %>
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "About", admin_about_path ] ].each do |label, path| %>
<%= link_to label, path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<% end %>
<% end %>
@@ -53,7 +53,7 @@
Admin <span aria-hidden="true" class="text-xs">▾</span>
</summary>
<div class="absolute right-0 z-30 mt-2 w-48 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ] ].each do |label, path| %>
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "About", admin_about_path ] ].each do |label, path| %>
<%= link_to label, path, class: [ "block px-4 py-2 text-sm hover:bg-slate-100", ("font-semibold text-sky-700" if current_page?(path)) ] %>
<% end %>
</div>