Skip to content

feat(api-keys): return real last_used in list + render in settings (rant 2026-08-24T12:41:25) - #140

Merged
argszero merged 1 commit into
mainfrom
feat/api-key-last-used
Aug 24, 2026
Merged

feat(api-keys): return real last_used in list + render in settings (rant 2026-08-24T12:41:25)#140
argszero merged 1 commit into
mainfrom
feat/api-key-last-used

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Settings page API Key "最近使用" (last used) column now shows real data instead of a hardcoded "从未" placeholder (rant 2026-08-24T12:41:25).

Findings: the api_keys.last_used column already existed and the gateway Bearer auth extractor already calls touch_api_key on every authenticated request (src/routes/mod.rs), so the column was being maintained — the gaps were:

  1. list_api_keys (src/dao.rs) didn't SELECT last_used, so the API never returned it
  2. Frontend renderSettings hardcoded last: T("settings.ak.last.never"), discarding any real value

Changes:

  • Backenddao::list_api_keys: SELECT last_used and return it in the JSON (null for never-used keys, UTC ISO string otherwise, converted via utc_iso)
  • FrontendrenderSettings: use k.last_used — real keys show the actual time (relative display + precise absolute time in the hover tooltip via timeCell); keys with null last_used show the "从未" placeholder
  • Test: extended api_keys_create_and_list_with_bearer — asserts the last_used field is present, is null for a freshly created unused key, and is a non-empty string when populated

Cache-bust 20260824-720260824-8.

Tests

  • cargo test 146/146 (incl. new last_used assertions), cargo fmt --check, cargo clippy green
  • node --check OK

@argszero
argszero merged commit 6821bfd into mainAug 24, 2026
1 check passed
@argszero
argszero deleted the feat/api-key-last-used branch August 24, 2026 05:17
Sign up for freeto 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

@argszero