mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 23:56:37 +08:00
refactor(admin): decouple system cleanup with event bus and enforce single owner principle
This commit is contained in:
@@ -255,3 +255,13 @@ func CreatePushHistoryRecord(ctx context.Context, history *entity.PushHistory) e
|
||||
func PushHistoryQuery(ctx context.Context) *gorm.DB {
|
||||
return GetDB(ctx).Model(&entity.PushHistory{})
|
||||
}
|
||||
|
||||
// DeletePushHistoriesBeforeRecord deletes push history records created before cutoff time.
|
||||
func DeletePushHistoriesBeforeRecord(ctx context.Context, cutoff time.Time) (int64, error) {
|
||||
db := GetDB(ctx)
|
||||
if db == nil {
|
||||
return 0, nil
|
||||
}
|
||||
result := db.Where("created_at < ?", cutoff).Delete(&entity.PushHistory{})
|
||||
return result.RowsAffected, result.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user