Skip to content

fix: remove total from usage#2930

Open
HarshMN2345 wants to merge 3 commits intomainfrom
fix-remove-totals-from-usage
Open

fix: remove total from usage#2930
HarshMN2345 wants to merge 3 commits intomainfrom
fix-remove-totals-from-usage

Conversation

@HarshMN2345
Copy link
Copy Markdown
Member

@HarshMN2345 HarshMN2345 commented Mar 25, 2026

What does this PR do?

image image image image

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

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.)

Summary by CodeRabbit

  • Improvements

    • Usage views across projects (databases, functions, sites, storage, auth, settings) now favor per-day/per-series displays: aggregate totals are hidden by default and labels updated to "per day"/"per billing period".
    • Charts now emphasize individual series with simplified legends and cumulative display options.
  • New Features

    • Legend can optionally hide numeric values.
    • Some pages include a period selector for quick timeframe changes.

@appwrite
Copy link
Copy Markdown

appwrite bot commented Mar 25, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Teams feature lets you group users with membership management and role permissions

@HarshMN2345 HarshMN2345 changed the title fix: remove usage fix: remove total from usage Mar 25, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

Walkthrough

This PR changes how aggregate totals are handled across the app: the single Usage component now defaults total to 0 and exposes showAggregateTotal: boolean = true; UsageMultiple was refactored to remove aggregate-total computation and related props, adding description and seriesNames and mapping series data directly. Many pages/components were updated to pass showAggregateTotal={false} (and in several places isCumulative) and to update count/legend titles to per-day wording. The Legend component gained a showValues prop. The settings usage page removed many aggregate total blocks and related computations; a period selector was added to the databases root usage page.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: remove total from usage' clearly summarizes the main change—removing totals from usage views across multiple components and pages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-remove-totals-from-usage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR removes aggregate total statistics (counts/sizes displayed above charts) from all usage pages across the Appwrite Console, replacing them with chart-only views. In usage.svelte and usageMultiple.svelte, a new backwards-compatible showAggregateTotal prop (default true) controls the display, and all relevant pages set it to false. The databases usage page additionally has its Usage component removed entirely (along with the "Total databases" cumulative chart), replaced by a standalone period selector above the reads/writes UsageMultiple chart. The settings/usage page removes totals for bandwidth, users, image transformations, screenshots, executions, storage, and GB hours.

Key changes:

  • New showAggregateTotal: boolean = true prop added to both Usage and UsageMultiple layout components — backwards-compatible default ensures no regressions in other consumers
  • 9 usage pages updated to pass showAggregateTotal={false}, hiding total-count displays while keeping charts intact
  • databases/usage/+page.svelte removes the databases count Usage component and introduces a standalone InputSelect period selector; the options list (24h, 30d, 90d) and navigation pattern are duplicated from usage.svelte, which is a minor maintenance concern
  • settings/usage/+page.svelte removes several *Total reactive variables and their associated display blocks; the total function import from usage.svelte is correctly cleaned up as it is no longer used

Confidence Score: 5/5

  • Safe to merge — changes are contained, backwards-compatible, and the intended UI is confirmed by the PR screenshots.
  • All changes are additive (new opt-in prop with a safe default) or straightforward removals of UI elements. No logic paths are broken, TypeScript types remain satisfied (total and count are still passed at every call site), and the reactive variable cleanup in settings/usage is complete. The only non-blocking concern is the duplicated period-selector options list in databases/usage/+page.svelte.
  • No files require special attention — the mild duplication in src/routes/(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte is worth a follow-up but is not a blocker.

Important Files Changed

Filename Overview
src/lib/layout/usage.svelte Adds backwards-compatible showAggregateTotal prop (default true) to conditionally hide the total count + label above the chart. Clean, safe change.
src/lib/layout/usageMultiple.svelte Adds showAggregateTotal prop (default true) mirroring the usage.svelte change. The totalCount computation is correctly moved inside the conditional block so it only runs when needed.
src/routes/(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte Removes the Usage component (and the "Total databases" chart entirely) and adds a standalone InputSelect period selector. Introduces a mild duplication of the period selector options that already exist in usage.svelte.
src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte Removes aggregate total displays (bandwidth, users, image transformations, screenshots, executions, storage, GB hours) and their corresponding reactive variables. Adjusts Phone OTP layout from u-main-space-between to u-main-end after removing the count display.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to the UsageMultiple component. Straightforward, no issues.
src/routes/(console)/project-[region]-[project]/functions/function-[function]/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to two Usage components (executions and GB hours). Clean change.
src/routes/(console)/project-[region]-[project]/functions/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to the Usage component. Simple, safe change.
src/routes/(console)/project-[region]-[project]/storage/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to the Usage component. Simple, safe change.
src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to both Usage components (files and transformations). Clean change.
src/routes/(console)/project-[region]-[project]/sites/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to the Usage component. Simple, safe change.
src/routes/(console)/project-[region]-[project]/sites/site-[site]/usage/[[period]]/+page.svelte Adds showAggregateTotal={false} to the Usage component. Simple, safe change.

Reviews (1): Last reviewed commit: "fix: remove usage" | Re-trigger Greptile

Comment on lines +23 to +44
<div
style:max-width="250px"
style:--input-background-color="var(--bgcolor-neutral-primary)">
<InputSelect
on:change={(e) => goto(`${usagePath}/${e.detail}`)}
id="period"
options={[
{
label: '24 hours',
value: '24h'
},
{
label: '30 days',
value: '30d'
},
{
label: '90 days',
value: '90d'
}
]}
value={page.params.period ?? '30d'} />
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Duplicated period selector options

The InputSelect options (24h, 30d, 90d) and the goto navigation pattern here are identical to the implementation already inside usage.svelte (lines 97–118). Since UsageMultiple with showHeader={false} has no built-in period selector, the standalone selector makes sense — but the options list is now duplicated in two places. If the period options ever change in usage.svelte, this page would need a matching update.

Consider extracting the options array to a shared constant (e.g. in a usage.svelte context module export or a helper file) so both places stay in sync automatically.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte (1)

350-357: ⚠️ Potential issue | 🟠 Major

Include build-only usage in the GB-hours empty-state check.

This card now says it covers executions and builds, but the {#if} still checks only data.usage.executionsMbSecondsTotal. Projects with build usage and zero executions will render “No data to show” even though the computed GB-hours total is non-zero.

🐛 Proposed fix
-            {`#if` data.usage.executionsMbSecondsTotal}
-                {`@const` totalGbHours = mbSecondsToGBHours(
-                    data.usage.executionsMbSecondsTotal + data.usage.buildsMbSecondsTotal
-                )}
+            {`@const` totalMbSeconds =
+                data.usage.executionsMbSecondsTotal + data.usage.buildsMbSecondsTotal}
+            {`#if` totalMbSeconds}
+                {`@const` totalGbHours = mbSecondsToGBHours(totalMbSeconds)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/routes/`(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte
around lines 350 - 357, The empty-state conditional currently checks only
data.usage.executionsMbSecondsTotal causing builds-only projects to show "No
data"; update the {`#if`} to consider the combined MB-seconds (executions +
builds) or the computed totalGbHours from mbSecondsToGBHours—e.g., compute
totalMbSeconds = data.usage.executionsMbSecondsTotal +
data.usage.buildsMbSecondsTotal (or reuse totalGbHours) and use that combined
value in the {`#if`} so the card renders when either executions or builds produce
usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/routes/`(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte:
- Around line 23-43: The period selector InputSelect (id="period") lacks an
accessible name; add one by either rendering a visible label element tied to the
control (e.g., <label for="period">Period</label>) placed before the InputSelect
or by passing an explicit accessible name prop/attribute (e.g.,
aria-label="Period" or aria-labelledby referencing a hidden label) so screen
readers can identify the combobox; update the InputSelect usage where
id="period" and the surrounding markup (and ensure styling keeps layout intact)
and keep the existing on:change/goto and value logic unchanged.

---

Outside diff comments:
In
`@src/routes/`(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte:
- Around line 350-357: The empty-state conditional currently checks only
data.usage.executionsMbSecondsTotal causing builds-only projects to show "No
data"; update the {`#if`} to consider the combined MB-seconds (executions +
builds) or the computed totalGbHours from mbSecondsToGBHours—e.g., compute
totalMbSeconds = data.usage.executionsMbSecondsTotal +
data.usage.buildsMbSecondsTotal (or reuse totalGbHours) and use that combined
value in the {`#if`} so the card renders when either executions or builds produce
usage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2b8499f-35a3-4069-b019-2a896f358b00

📥 Commits

Reviewing files that changed from the base of the PR and between 5251384 and b4a2fad.

📒 Files selected for processing (11)
  • src/lib/layout/usage.svelte
  • src/lib/layout/usageMultiple.svelte
  • src/routes/(console)/project-[region]-[project]/databases/database-[database]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/functions/function-[function]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/functions/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/sites/site-[site]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/sites/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/storage/usage/[[period]]/+page.svelte

Comment on lines +23 to +43
<div
style:max-width="250px"
style:--input-background-color="var(--bgcolor-neutral-primary)">
<InputSelect
on:change={(e) => goto(`${usagePath}/${e.detail}`)}
id="period"
options={[
{
label: '24 hours',
value: '24h'
},
{
label: '30 days',
value: '30d'
},
{
label: '90 days',
value: '90d'
}
]}
value={page.params.period ?? '30d'} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add an accessible name to the standalone period selector.

This InputSelect no longer lives inside the shared usage header, but it still has no visible label or other accessible name. Screen readers will treat it as an unlabeled combobox.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/routes/`(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte
around lines 23 - 43, The period selector InputSelect (id="period") lacks an
accessible name; add one by either rendering a visible label element tied to the
control (e.g., <label for="period">Period</label>) placed before the InputSelect
or by passing an explicit accessible name prop/attribute (e.g.,
aria-label="Period" or aria-labelledby referencing a hidden label) so screen
readers can identify the combobox; update the InputSelect usage where
id="period" and the surrounding markup (and ensure styling keeps layout intact)
and keep the existing on:change/goto and value logic unchanged.

Copy link
Copy Markdown
Contributor

@stnguyen90 stnguyen90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HarshMN2345 these are still total stats. We don't want to show any total stats. Instead, we want stuff like reads per day or writes per day or executions per day.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/lib/layout/usageMultiple.svelte (1)

10-11: Consider validating array length alignment between count and seriesNames.

seriesNames[index] at line 33 assumes the arrays have matching lengths. If a caller passes mismatched arrays (e.g., 3 metrics series but only 2 names), the chart would render undefined as the series name for the extra items.

This is likely a minor concern if callers are expected to maintain consistency, but a defensive check or TypeScript tuple type could prevent subtle bugs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/layout/usageMultiple.svelte` around lines 10 - 11, Add a defensive
validation for the exported props count and seriesNames: check that count.length
=== seriesNames.length when the component initializes (e.g., in the script block
or onMount) and either throw a clear error or normalize by supplying a fallback
name for missing entries (use seriesNames[i] ?? `series ${i + 1}`) before the
code that uses seriesNames[index] to render series; reference the exported
variables count and seriesNames and the place where seriesNames[index] is used
to ensure the check runs prior to rendering.
src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte (1)

21-31: Remove unused data fetching from the loader.

The data loader in +page.ts (lines 60-62) still computes filesStorageTotal, usersTotal, and executionsTotal from aggregations, but these values are never accessed in +page.svelte. Removing these unused assignments will clean up unnecessary server-side processing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/routes/`(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte
around lines 21 - 31, The loader is computing unused aggregations — remove the
calculations and assignments for filesStorageTotal, usersTotal, and
executionsTotal from the page loader (the code that builds the returned data
object), and stop including them in the returned data so server work is not
wasted; locate the loader function that sets data.usage and remove the lines
that compute filesStorageTotal, usersTotal, and executionsTotal (and any related
aggregation calls) and ensure data.usage still contains only the fields
referenced by the Svelte page (network, users, executions, imageTransformations,
screenshotsGenerated, databasesReads, databasesWrites).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/lib/layout/usageMultiple.svelte`:
- Around line 10-11: Add a defensive validation for the exported props count and
seriesNames: check that count.length === seriesNames.length when the component
initializes (e.g., in the script block or onMount) and either throw a clear
error or normalize by supplying a fallback name for missing entries (use
seriesNames[i] ?? `series ${i + 1}`) before the code that uses
seriesNames[index] to render series; reference the exported variables count and
seriesNames and the place where seriesNames[index] is used to ensure the check
runs prior to rendering.

In
`@src/routes/`(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte:
- Around line 21-31: The loader is computing unused aggregations — remove the
calculations and assignments for filesStorageTotal, usersTotal, and
executionsTotal from the page loader (the code that builds the returned data
object), and stop including them in the returned data so server work is not
wasted; locate the loader function that sets data.usage and remove the lines
that compute filesStorageTotal, usersTotal, and executionsTotal (and any related
aggregation calls) and ensure data.usage still contains only the fields
referenced by the Svelte page (network, users, executions, imageTransformations,
screenshotsGenerated, databasesReads, databasesWrites).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a1a542c-ec03-44a3-8b02-847fd4b59e55

📥 Commits

Reviewing files that changed from the base of the PR and between b4a2fad and 3910ed2.

📒 Files selected for processing (16)
  • src/lib/charts/legend.svelte
  • src/lib/layout/usage.svelte
  • src/lib/layout/usageMultiple.svelte
  • src/routes/(console)/project-[region]-[project]/auth/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/views/usage/view.svelte
  • src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/databases/database-[database]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/functions/function-[function]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/functions/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.ts
  • src/routes/(console)/project-[region]-[project]/sites/site-[site]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/sites/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/storage/usage/[[period]]/+page.svelte
💤 Files with no reviewable changes (1)
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/routes/(console)/project-[region]-[project]/functions/usage/[[period]]/+page.svelte
  • src/lib/layout/usage.svelte
  • src/routes/(console)/project-[region]-[project]/sites/site-[site]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/storage/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/functions/function-[function]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/databases/database-[database]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/databases/usage/[[period]]/+page.svelte
  • src/routes/(console)/project-[region]-[project]/sites/usage/[[period]]/+page.svelte

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