Today's ticket summary for the support desk

Ruby · Rails · intermediate · modification

Adds the endpoint behind the new "Today" tile on the support desk's wall screen. `Ticket` (`app/models/ticket.rb`) gets two scopes, `opened_on(date)` and `resolved_on(date)`, which turn a date into that day's range in the app's time zone with `in_time_zone.all_day` and filter `created_at` or `resolved_at` on it. The new `DailySummariesController#show` (`app/controllers/daily_summaries_controller.rb`) takes today's date and returns it with the two counts; `config/routes.rb` adds `resource :daily_summary, only: :show`. `test/controllers/daily_summaries_controller_test.rb` (new) adds integration tests with `travel_to`: a day with tickets opened and resolved around it, an empty day, and the request without a token.

Ruby 4.0, Rails 8.1 JSON API (`ApplicationController < ActionController::API`), SQLite in development and test, PostgreSQL 16 in production; nothing in this change depends on the database. Existing and unchanged: `config.time_zone = "Europe/Berlin"`, and Active Record keeps its default of storing timestamps in UTC; the production containers and CI run with the process time zone unset, so the operating system clock is UTC there, while developers' laptops are on Berlin time. `ApplicationController` includes the app's `Authentication` concern, whose `before_action :require_authentication` reads the `Authorization: Bearer <token>` header with `authenticate_with_http_token`, looks the agent up with `User.find_by(api_token: token)` (`users.api_token` is `null: false` with a unique index, generated by `has_secure_token`), answers 401 when the header is missing or the token matches no user, and otherwise sets `Current.user`; the app is the desk's single-tenant internal tool, so there is no per-account scoping. The `tickets` table has `subject` (`null: false`), `created_at`, and `resolved_at` (nullable: `nil` while the ticket is open, the time of resolution otherwise, cleared when a ticket is reopened), with indexes on `created_at` and `resolved_at`. The wall screen (shipped separately) polls this endpoint every minute and shows the three fields as they come.

Requirements

Files touched

Review this PR

Ruby practice