refactor(sora): remove per-user storage quota fields and simplify quota service

- Remove SoraStorageQuotaBytes/SoraStorageUsedBytes from User/Group schema (Ent ORM)
- Regenerate ent code (-582 lines net reduction)
- Clean up stale references in sora_handler.go (4 sites) and service.User struct
- Simplify SoraQuotaService constructor (3-param -> 1-param, system-default only)
- Add Deprecated marker + HTTP headers to ClearUserStorage API
- Change AddUsage/ReleaseUsage log level to Debug
- Add 9 unit tests for simplified SoraQuotaService (boundary/negative/nil-safe)
- Fix test files to remove deleted field references

Code review: 8.0/10 overall rating, 0 critical issues remaining.
This commit is contained in:
User
2026-04-18 10:12:37 +08:00
parent 1a483baa90
commit d1bf033f24
28 changed files with 200 additions and 1335 deletions

View File

@@ -155,15 +155,12 @@ func TestNewSoraHandler(t *testing.T) {
func TestUser_SoraFields(t *testing.T) {
user := &service.User{
ID: 1,
Email: "test@example.com",
SoraStorageQuotaBytes: 10 * 1024 * 1024 * 1024,
SoraStorageUsedBytes: 1 * 1024 * 1024 * 1024,
ID: 1,
Email: "test@example.com",
}
assert.Equal(t, int64(1), user.ID)
assert.Equal(t, int64(10*1024*1024*1024), user.SoraStorageQuotaBytes)
assert.Equal(t, int64(1*1024*1024*1024), user.SoraStorageUsedBytes)
assert.Equal(t, "test@example.com", user.Email)
}
func TestQuotaInfo_Fields(t *testing.T) {