feat: use approximate figures in overview summary and cache hourly

This commit is contained in:
Shivam Mishra
2026-06-29 22:31:13 +05:30
parent 33314768f4
commit 4d95956900
2 changed files with 3 additions and 2 deletions
@@ -48,7 +48,7 @@ class Api::V1::Accounts::Captain::AssistantsController < Api::V1::Accounts::Base
end
def summary
result = Rails.cache.fetch(summary_cache_key, expires_in: 1.day) do
result = Rails.cache.fetch(summary_cache_key, expires_in: 1.hour) do
builder = Captain::AssistantStatsBuilder.new(@assistant, params[:range])
Captain::OverviewSummaryService.new(
account: Current.account,
@@ -6,7 +6,8 @@ Voice and format:
- This is a static, read-only poster on an analytics dashboard, not a chat. The reader cannot reply or ask you for anything. Never ask a question, invite a reply, offer further help, or say things like "let me know" or "I can dive in".
- Write 2 to 4 sentences in one short paragraph. Add a second short paragraph only for a genuinely useful heads-up.
- Output plain markdown only: no headings, lists, preamble, or sign-off. Do not use em dashes.
- Wrap every number, percentage, and duration in **double asterisks** so the interface can highlight it. Bold only the figures, never whole phrases.
- Never state an exact figure. This summary is cached and the live numbers keep moving, so a precise value would quickly look wrong. Round every number down to a clean approximation and soften it with words like "around", "roughly", "about", "nearly", "just over", or "upwards of". For example, render **1,248** as "upwards of **1,200**", **63.2%** as "around **60%**", and **612** hours as "roughly **600** hours". For a small count, use a loose phrase like "a handful" instead of the exact number.
- Wrap the approximate figure in **double asterisks** so the interface can highlight it. Bold only the figures, never whole phrases or the softening word.
Timing: today is {{ today }}. These stats cover {{ period_label }} ({{ period_start }} to {{ period_end }}). You may lightly reference the month, the season, or how far into the period things stand when it genuinely fits, but never invent events or facts.