fix(wake): faturamento defaults its comparison; document dashboard buckets and order sort

Merged
TH
4d ago
+55-9

Why

I tested #600 against a live store right after its deploy (1.1.0). Every new tool answered, but three things needed a fix or a word in the docs:

  1. WAKE_DASHBOARD faturamento failed with HTTP 422 whenever the caller gave no comparison period: Wake requires dataInicialComparativo and dataFinalComparativo.
  2. The dashboard buckets don't all mean the same thing, and nothing said so:
    • captados is by order date. For one day it matched WAKE_LIST_ORDERS exactly, in count and in revenue, also when summed across the 24 hourly buckets.
    • cancelados matched the orders that moved to a canceled status that day (enumTipoFiltroData=DataModificacaoStatus, statuses 3–8), whenever they were placed. So pagos, enviados and cancelados are event-dated.
    • carrinhoAbandonado leaves out dataFinal: a range that starts and ends on the same day returns 0.
  3. /pedidos sorts by the order date (data) whatever enumTipoFiltroData says. The tool description implied it sorted by the filter date.

What

  • faturamento now compares with the same number of days just before (previousPeriod) when no comparison dates are given. Explicit dates still win.
  • WAKE_DASHBOARD's description, the field descriptions and the README say which buckets are by order date and which are event-dated, and note the carrinhoAbandonado end-date behaviour.
  • WAKE_LIST_ORDERS describes the sort order correctly.
  • Version bumped to 1.1.1.

Verified

  • bun test (wake): 24 pass. That includes previousPeriod, for a single day and for a range that crosses a month.
  • scripts/check.ts wake, oxfmt --check, oxlint (the only wake warning predates this) and check:registry are clean.
  • The bucket behaviour above was measured live on 1.1.0. After deploy I'll call faturamento without comparison dates on the same connection.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes the Wake WAKE_DASHBOARD faturamento tool failing with HTTP 422 when no comparison period is given, and documents the actual semantics of dashboard buckets and list ordering.

  • faturamento now defaults to the period of equal length immediately before; explicit comparison dates still win.
  • Documents that only captados counts by order date; pagos, enviados, and cancelados count orders that reached that state in the bucket, and that carrinhoAbandonado ignores dataFinal.
  • WAKE_LIST_ORDERS now states that rows always sort by the order date, regardless of the date filter.