This commit is contained in:
ryan
2026-07-13 15:17:45 +08:00
parent 08e61ce833
commit e0eb4e5975
334 changed files with 17212 additions and 12321 deletions
+1 -1
View File
@@ -93,4 +93,4 @@ func applyFilter(query *gorm.DB, filter AccessLogFilter) *gorm.DB {
query = query.Where("created_at <= ?", *filter.EndTime)
}
return query
}
}
@@ -14,4 +14,4 @@ type AccessLogFilter struct {
StartTime *time.Time
// EndTime filters created_at <= EndTime when non-nil.
EndTime *time.Time
}
}
@@ -156,4 +156,4 @@ func GetTopActiveUsers(ctx context.Context, startTime time.Time, limit int) ([]T
return nil, fmt.Errorf("get top active users: %w", err)
}
return users, nil
}
}
@@ -141,10 +141,10 @@ func TestBatchInsert_UsesModelBatchSQL(t *testing.T) {
}
type mockConn struct {
batch driver.Batch
batchQuery string
prepareCalled bool
preparedQuery string
batch driver.Batch
batchQuery string
prepareCalled bool
preparedQuery string
}
func (m *mockConn) Contributors() []string { return nil }
@@ -204,4 +204,4 @@ func (m *mockBatch) Rows() int { return len(m.rows) }
func (m *mockBatch) Columns() []column.Interface { return nil }
func (m *mockBatch) Close() error { return nil }
func (m *mockBatch) Close() error { return nil }
@@ -46,4 +46,4 @@ func BatchInsert(ctx context.Context, logs []analyticsmodel.UserAccessLog) error
return fmt.Errorf("send clickhouse batch: %w", err)
}
return nil
}
}
+1 -1
View File
@@ -27,4 +27,4 @@ func ParseBrowserName(ua string) string {
return "Safari"
}
return "Other"
}
}
@@ -38,7 +38,7 @@ func setupAuthSourceCacheTest(t *testing.T) (*gorm.DB, *miniredis.Miniredis, fun
db.SetDB(sqliteDB)
db.Redis = redis.NewClient(&redis.Options{
Addr: miniRedis.Addr(),
Addr: miniRedis.Addr(),
MaintNotificationsConfig: &maintnotifications.Config{
Mode: maintnotifications.ModeDisabled,
},
@@ -237,4 +237,4 @@ func TestAuthSourceInvalidationPubSubClearsPeerRAM(t *testing.T) {
if _, ok := authSourceActiveRAM.GetIfPresent(authSourceActiveRAMKey); ok {
t.Fatal("expected peer RAM cache to be cleared by pub/sub")
}
}
}
+1 -1
View File
@@ -102,4 +102,4 @@ func DeleteActivePushChannelCache(ctx context.Context, name string) {
if db.Redis != nil {
_ = db.Redis.Del(ctx, db.PrefixedKey("push:channel:active:"+name)).Err()
}
}
}
+1 -1
View File
@@ -121,4 +121,4 @@ func DeleteActivePushEventCache(ctx context.Context, key string) {
if db.Redis != nil {
_ = db.Redis.Del(ctx, db.PrefixedKey("push:event:active:"+key)).Err()
}
}
}
+1 -1
View File
@@ -51,4 +51,4 @@ func CreatePushHistory(ctx context.Context, history *model.PushHistory) error {
// PushHistoryQuery returns a scoped query builder for push histories.
func PushHistoryQuery(ctx context.Context) *gorm.DB {
return db.DB(ctx).Model(&model.PushHistory{})
}
}
+5 -6
View File
@@ -21,10 +21,10 @@ import (
const (
configTypeSystem = "system"
errDatabaseNotInitialized = "database not initialized"
errConfigIntParseFailed = "配置 %s 的值 '%s' 无法转换为整数: %w"
errConfigDecimalParseFailed = "配置 %s 的值 '%s' 无法转换为decimal: %w"
errConfigBoolParseFailed = "配置 %s 的值 '%s' 无法转换为布尔值: %w"
errParseMenuDisplayConfigFailed = "解析目录显示配置失败: %w"
errConfigIntParseFailed = "配置 %s 的值 '%s' 无法转换为整数: %w"
errConfigDecimalParseFailed = "配置 %s 的值 '%s' 无法转换为decimal: %w"
errConfigBoolParseFailed = "配置 %s 的值 '%s' 无法转换为布尔值: %w"
errParseMenuDisplayConfigFailed = "解析目录显示配置失败: %w"
)
// PreheatSystemConfigs loads all system configs from database.
@@ -198,7 +198,6 @@ func ListVisibleSystemConfigs(ctx context.Context) ([]model.SystemConfig, error)
return configs, nil
}
// GetIntByKey queries config and converts to int.
func GetIntByKey(ctx context.Context, key string) (int, error) {
sc, err := GetSystemConfigByKey(ctx, key)
@@ -261,4 +260,4 @@ func GetMenuDisplayConfig(ctx context.Context) (map[string]bool, error) {
}
return config, nil
}
}
+1 -1
View File
@@ -82,4 +82,4 @@ func SaveOrUpdateSystemConfig(ctx context.Context, key, value string) error {
}
}
return InvalidateSystemConfigCache(ctx, key)
}
}
+1 -2
View File
@@ -56,7 +56,6 @@ func setupSystemConfigTest(t *testing.T) (*gorm.DB, func()) {
db.SetDB(sqliteDB)
db.Redis = redisClient
cleanup := func() {
StopSystemConfigCacheListener()
ResetSystemConfigRAMCacheForTest()
@@ -156,4 +155,4 @@ func TestGetSystemConfigByGroupAndInvalidation(t *testing.T) {
if updated.Value != "new_site_name" {
t.Fatalf("value = %q, want %q", updated.Value, "new_site_name")
}
}
}
+1 -1
View File
@@ -56,4 +56,4 @@ func SaveTemplate(ctx context.Context, tmpl *model.Template) error {
// DeleteTemplate removes a template record.
func DeleteTemplate(ctx context.Context, tmpl *model.Template) error {
return db.DB(ctx).Delete(tmpl).Error
}
}
+1 -1
View File
@@ -127,4 +127,4 @@ func ListUploadsByIDs(ctx context.Context, ids []uint64) ([]model.Upload, error)
// UploadQuery returns a scoped GORM query for uploads.
func UploadQuery(ctx context.Context) *gorm.DB {
return db.DB(ctx).Model(&model.Upload{})
}
}
+1 -1
View File
@@ -17,4 +17,4 @@ func ListUploadStats(ctx context.Context) ([]model.UploadStat, error) {
return nil, err
}
return stats, nil
}
}