Repository navigation
feat: GET /usage と alteroid usage に、基準ごとの累積の数え直しの回数と最終時刻を出す - #5412
Merged
Merged
Conversation
reset の発生を日誌を引かずに見張れるようにする(読み取りだけ。書き込みと基準の保存は変えない)。 - UsageAggregate に任意の resets 欄(layer・managerId・resets・lastResetAt?)を足した。基準が1件でもあるときだけ載せ、0 回の基準は回数 0・最終時刻なし。日付に依らない現在値で、layer / managerId だけで絞る。 - 3実装(インメモリ / fs / pg)の aggregate() が同じ関数(resetRowsOfBaselines)で作る。 - alteroid usage は、1回以上ある基準だけ1行ずつ出す。0 回は出さない。 - openapi.json を再生成した。契約の試験(verifyUsageResetsContract)を3実装に当てた。
基準が1件でもある台帳の応答には resets が載る(Issue #5409)。この試験が測るのは unmeteredRows の鍵が無いことで、resets とは別。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #5409 を参照(案 A。#5402・#5406・#5407 の続き)。
内容
reset の発生を、日誌を引かずに見張れるようにする。読み取りだけで、書き込みと基準の保存は変えない。
UsageAggregate(aggregate()の戻り、GET /usageの応答)に、任意のresets: [{layer, managerId, resets, lastResetAt?}]を足した。基準(層 × 担当)ごとの回数と最終時刻。lastResetAt無し(「数え直しが無い」と「基準が無い」を区別するため)。from/to/site/tokenIdでは絞らず、layer/managerIdだけで絞る(基準は日付を持たないため)。並びは層、managerId の順。aggregate()が、同じ関数(resetRowsOfBaselines)で作る。pg はusage_baselineを(絞り込み付きで)select。alteroid usageは、1回以上ある基準だけ 1 行ずつ出す(0 回は出さない。0 回だけ・欄なしなら出力は 1 文字も変わらない)。--jsonは無い現状のまま。apps/daemon/openapi.jsonを再生成した(pnpm -C apps/daemon build)。既存クライアントへの影響
任意欄の追加だけで、既存の欄は変えていない。欄を知らないクライアントは無視でき、
resetsを読まない CLI の出力も変わらない。ただし基準が1件でもある台帳の応答にはresetsが載る(pg の「既存の応答を変えない」試験の鍵の一覧にresetsを足した)。案 B(
resetの行へ「欠落ぶんで判定した」印を足す案)は入れないschema を増やすので、A で足りるかを見てから。
試験
verifyUsageResetsContract)を3実装に当てた: 数え直しの後に回数・最終時刻が読める、基準に reset が無ければ 0 回で最終時刻なし、layer / managerId で絞れる、日付で絞っても変わらない、該当が無ければ欄ごと無い。GET /usageの応答(絞り込み・日付に依らない)と、alteroid usageの表示(1 回以上だけ・0 回は出さない・導入前と出力が変わらない)。変異の確認
resetRowsOfBaselinesが空を返す)にすると、契約の3実装(インメモリ・fs・pg)とGET /usageの試験が落ちた。describeUsageResetsを外す)にすると、CLI の表示の試験 2 本が落ちた。限界
判定そのものは推定で、誤って数え直しとみなす(過大)も拾えない(過少)もありうる。この口は、回数が増え続けていないかを見張るためのもの。過去分の台帳は補正しない。