Skip to content

fix: correct function usage period totals#3022

Merged
HarshMN2345 merged 3 commits intomainfrom
codex/fix-function-usage-period-totals
May 5, 2026
Merged

fix: correct function usage period totals#3022
HarshMN2345 merged 3 commits intomainfrom
codex/fix-function-usage-period-totals

Conversation

@HarshMN2345
Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

image image image image image

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@HarshMN2345 HarshMN2345 requested a review from lohanidamodar May 5, 2026 06:49
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

  • Migrates the function usage page from Svelte 4 reactive declarations (export let data, $:) to Svelte 5 ($props(), $derived), and replaces the API-provided executionsTotal with a sum computed from the period's metric series so that the displayed total reflects the selected time window rather than a lifetime value.
  • Adds isCumulative to both Usage chart components, switching from the accumulateFromEndingTotal chart projection to plotting per-period values directly, consistent with the new sum-based totals.
  • The previously flagged P1 (always-truthy {#if count} array guard) is addressed in this PR by changing to {#if count.length}.

Confidence Score: 4/5

Safe to merge; no P0 issues found and the previously reported P1 (always-truthy array guard) has been resolved.

The only open concern is the rename from data.executionsMbSeconds to data.executionsTime — if the SDK type does not expose executionsTime, the GB-hours card would silently never render. However, since the page uses typed PageProps, TypeScript would catch a missing field at build time, so the risk is low. All other logic is correct.

No files require special attention beyond verifying the executionsTime field exists in the SDK type for functions.getUsage().

Important Files Changed

Filename Overview
src/routes/(console)/project-[region]-[project]/functions/function-[function]/usage/[[period]]/+page.svelte Migrates from Svelte 4 reactive declarations to Svelte 5 $derived, fixes period-total computation by summing series values instead of using the server-provided executionsTotal, adds isCumulative to both Usage cards, and renames executionsMbSeconds to executionsTime. One previously flagged P1 (always-truthy {#if count} guard) is resolved; gbHoursTotal is computed from the filtered gbHoursCount array, which is mathematically correct since filtered-out zeros do not affect the sum.

Reviews (2): Last reviewed commit: "refactor: improve periodic usage charts" | Re-trigger Greptile

@HarshMN2345 HarshMN2345 merged commit 524d89d into main May 5, 2026
3 checks passed
@HarshMN2345 HarshMN2345 deleted the codex/fix-function-usage-period-totals branch May 5, 2026 07:04
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