Ticket summary for the support dashboard

Ruby · Rails · intermediate · modification

Adds the ticket summary behind the support dashboard's header counters. `config/routes.rb` routes `GET /ticket_summary` to the new `TicketSummariesController#show`, which accepts a 7- or 30-day period, counts the account's opened, solved and unsolved tickets and keeps the result in `Rails.cache` for ten minutes, since the dashboard polls it every minute. `app/models/ticket.rb` gains two scopes, `opened_since` and `solved_since`, for the period counts (`not_solved` comes from the existing enum). `test/controllers/ticket_summaries_controller_test.rb` adds integration tests for the default and 30-day counts, an unsupported period and the missing-token case.

Rails 8.1 API app on Ruby 4.0, Minitest integration tests with inline records (`ActiveSupport::Testing::TimeHelpers` available). SQLite in development and test, PostgreSQL 16 in production; nothing in this PR depends on which one. `config.time_zone` is the default UTC. The production `config.cache_store` is Solid Cache, one store shared by every app server and worker; the test environment keeps the default `:null_store`. The app hosts many customer accounts (a multi-tenant helpdesk). `ApplicationController` (existing, unchanged) is an `ActionController::API` that includes the `Authentication` concern: a `before_action` looks up `User.find_by(api_token:)` from the bearer token, answers 401 itself when there is none, and sets `Current.user`; `Current.account` delegates to `Current.user.account`. Models (existing, unchanged apart from the new scopes): `Account` `has_many :users, :tickets`; `User` (`name`, `api_token`) `belongs_to :account`; `Ticket` (`subject` `NOT NULL`, `status` `NOT NULL DEFAULT 0` (`open`), nullable `solved_at`) `belongs_to :account` with `enum :status, { open: 0, pending: 1, solved: 2 }`; the existing ticket workflow sets `solved_at` when a ticket is solved and clears it when the ticket is reopened. `tickets` has indexes on `[account_id, created_at]` and `[account_id, solved_at]`. The dashboard itself ships separately in the web app.

Requirements

Files touched

Review this PR

Ruby practice