Skip to content

Unify admin storage usage metrics - #326

Merged
Rabithua merged 1 commit into
mainfrom
develop
Aug 14, 2026
Merged

Unify admin storage usage metrics#326
Rabithua merged 1 commit into
mainfrom
develop

Conversation

@Rabithua

Copy link
Copy Markdown
Owner

Summary

  • use the authoritative resource storage ledger for the official rote.ink admin storage ranking
  • keep the existing attachment-size calculation for self-hosted instances
  • use the same metric for displayed usage and ranking order

Root cause

The user resource screen read resource_storage_accounts.used_bytes, while the admin dashboard still summed client-declared attachment sizes. This produced different totals for the same user.

Validation

  • bun run build
  • bunx eslint utils/dbMethods/admin.ts
  • git diff --check

@Rabithua
Rabithua merged commit 8cb75b9 into main Aug 14, 2026
7 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebf1b1ec6d

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +319 to +323
? sql<number>`COALESCE((
SELECT ${resourceStorageAccounts.usedBytes}
FROM ${resourceStorageAccounts}
WHERE ${resourceStorageAccounts.userId} = ${users.id}
), 0)::bigint`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep unreconciled storage usage unknown

When billing is enabled while the initial storage reconciliation is pending or failed, this query converts a missing account to zero and exposes nonzero accounts even if reconciledAt is null. In contrast, reportedOfficialUsedBytes in resources/service.ts returns null until the account or global reconciliation is complete. Consequently, the admin dashboard can filter out legacy users as having no usage or rank them using a partial ledger, so it still disagrees with the user resource screen during rollout; preserve the unreconciled state instead of silently coercing it to a usable total.

AGENTS.md reference: AGENTS.md:L48-L50

Useful? React with 馃憤聽/ 馃憥.

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.

1 participant