fix(stats): last_usage orders by id (insertion order); clarify Window default
This commit is contained in:
parent
f2f104627d
commit
59dd7955aa
2 changed files with 5 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ impl Window {
|
|||
"7d" => Self::Week,
|
||||
"30d" => Self::Month,
|
||||
"all" => Self::All,
|
||||
// Default (incl. `label()`'s own canonical `"24h"`/`"1d"`).
|
||||
_ => Self::Day,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,7 +289,10 @@ impl TurnStats {
|
|||
last_input_tokens, last_output_tokens,
|
||||
last_cache_read_input_tokens, last_cache_creation_input_tokens
|
||||
FROM turn_stats
|
||||
ORDER BY started_at DESC
|
||||
-- `id` (AUTOINCREMENT) is monotonic with insertion, so this is
|
||||
-- the most-recently-inserted row even among same-second turns
|
||||
-- (which `started_at DESC` would order arbitrarily).
|
||||
ORDER BY id DESC
|
||||
LIMIT 1",
|
||||
[],
|
||||
|row| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue