Repository navigation
feat(admin): show which users shared which models - #457
Merged
Merged
Conversation
Admins had no single place to see who is sharing models and which models each member shares: the sharing list exposed the raw key rows, so the answer had to be assembled by eye from a flat table. Add an admin-only GET /api/admin/sharings that aggregates the keys table by member and by model — quota, used, live/paused/off key counts, the last creation time, and the models each member shares — and add a fifth "Sharing overview" tab to the admin view rendering it with stat cards, a per-member table, a per-model table and a search box. No schema change: the aggregate reads columns that already exist, and the keys table is small enough that a full scan is the right plan. Closes #456
Merged
argszero
added a commit
that referenced
this pull request
Dec 3, 2026
Cut v0.7.37 over the one commit since v0.7.36: the admin sharing overview (#457), which adds an admin-only GET /api/admin/sharings and a fifth "Sharing overview" tab in the admin view. Version string moved 0.7.36 -> 0.7.37 in the five carriers (8 places) and a matching CHANGELOG section. No schema change: SCHEMA_VERSION stays 18. cargo test 617/0 (616 at v0.7.36); fmt and clippy clean.
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.
What this does
Admins had no single place to answer "who is sharing models, and which models do they share?". The sharing list shows raw key rows, so the answer had to be assembled by eye.
This adds an admin-only
GET /api/admin/sharingsand a fifth Sharing overview tab to the admin view.Host request, translated from Chinese:
Design discussion: #456. Closes #456.
API
GET /api/admin/sharings— admin only,403for everyone else, same guard and same response style asGET /api/admin/usage.The two questions are each other's inverse, so one pass over the data answers both:
users[]— aggregated per sharer:user_id,email,name,dept_name,keys{on,paused,off},keys_live,quota,used,last_created_at, andmodels[](eachprovider,model,keys{on,paused,off},keys_live).models[]— aggregated per(provider, model): the samekeys/keys_live/quota/used, plussharers(a count of people) andowners[](user_id,email,name).totals—users,models,keys{on,paused,off},keys_live.Data source is the existing
keystable (one row = one listing), with the sharer taken askeys.owner_id→users.id.A row with
status = 'off'is a listing taken down: it leaves both rosters, because it serves no traffic, but it is still counted inkeys.off, so nothing is hidden — only no longer called "sharing right now".No key material is selected at all:
encrypted_keynever enters the query, so the response cannot carry a plaintext, masked or encrypted key.UI
ui/index.htmlfori18n.jsandapp.js.Gates
Measured on this branch:
cargo test— 617 passed, 0 failed, including the newroutes::tests::admin_sharings_lists_who_shared_what, which asserts four things at once: 403 for a non-admin; members appear once each with only their own models; two members sharing one model givesharers: 2not two listings; astatus='off'row leaves both rosters whiletotals.keys.offstill counts it; and no key value of any kind appears in the body.cargo clippy --all-targets -- -D warnings— clean.cargo fmt --check— clean.table_gate7 → 8 tables,state_gategains#sharing-search, and the six i18n constants ini18n_pack.rsmove to their new values.Not in this change
No schema change: the aggregate reads columns that already exist, and
SCHEMA_VERSIONstays 18. No index onkeys.owner_ideither — the keys table is a listing table (a member's listings are single-digit), so a full scan is cheaper than an index that would moveSCHEMA_VERSION.