Skip to content

fix: reconstruct ProviderUsage subtypes on DB read and preserve StatusProviderUsage through pipeline#654

Open
rygel wants to merge 20 commits into
developfrom
feat/cycle-20-web-clean
Open

fix: reconstruct ProviderUsage subtypes on DB read and preserve StatusProviderUsage through pipeline#654
rygel wants to merge 20 commits into
developfrom
feat/cycle-20-web-clean

Conversation

@rygel

@rygel rygel commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Follow-up fixes to PR #653 (ProviderUsage shape contract).

Changes

  • DB read path: The \card_type\ discriminator column was written on every INSERT but never read. All \QueryAsync\ calls materialised every row as \WindowedProviderUsage, silently dropping \ModelName\ and \StatusProviderUsage\ type identity. Added \HistoryRowDto\ + \ToTypedUsage\ switch that reconstructs the correct subtype.

  • Web mapper: \WebProviderUsageMapper.Map\ always created \QuotaProviderUsage. Now checks \card_type\ and creates \StatusProviderUsage\ when appropriate.

  • Processing pipeline: \NormalizeUsage\ was converting \StatusProviderUsage\ into \QuotaProviderUsage\ with zero quota values. Now preserves the \StatusProviderUsage\ type and only sets quota fields for \QuotaProviderUsage\ subtypes.

- Add [JsonDerivedType] attributes for polymorphic serialization
- Create QuotaProviderUsage (RequestsUsed, RequestsAvailable, etc.)
- Create WindowedProviderUsage (window/group/card properties)
- Create ModelScopedProviderUsage (per-model quota cards)
- Create StatusProviderUsage (status-only, no quota data)
- Bridge new ProviderUsage() calls to QuotaProviderUsage temporarily
The card_type column was written on every INSERT but never consulted
on read — all four QueryAsync calls materialised every row as
WindowedProviderUsage, silently losing ModelName (model-scoped) and
type identity (status providers).

Added HistoryRowDto for Dapper mapping and ToTypedUsage switch that
reconstructs StatusProviderUsage / QuotaProviderUsage /
ModelScopedProviderUsage / WindowedProviderUsage based on card_type.

Updated WebProviderUsageMapper to check card_type for the Web path.
NormalizeUsage was converting StatusProviderUsage into QuotaProviderUsage
with zero quota values, losing the type identity. Now creates the correct
subtype and only sets quota fields when the candidate is a QuotaProviderUsage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants