Unify organize ingest pipeline

This commit is contained in:
ShukeBta
2026-06-14 23:17:52 +08:00
parent a623702276
commit 479a06f008
41 changed files with 3075 additions and 728 deletions
+22 -2
View File
@@ -809,13 +809,33 @@ func (r *SubscriptionRepository) Create(ctx context.Context, s *model.Subscripti
return r.db.WithContext(ctx).Select("*").Omit("DeletedAt").Create(s).Error
}
// List returns all subscription rules.
// List returns active subscription rules. Archived rows live in history and are
// intentionally excluded from scheduler polling and the active management list.
func (r *SubscriptionRepository) List(ctx context.Context) ([]model.Subscription, error) {
var rows []model.Subscription
err := r.db.WithContext(ctx).Order("created_at desc").Find(&rows).Error
err := r.db.WithContext(ctx).Where("archived_at IS NULL").Order("created_at desc").Find(&rows).Error
return rows, err
}
// History returns archived subscription rules.
func (r *SubscriptionRepository) History(ctx context.Context) ([]model.Subscription, error) {
var rows []model.Subscription
err := r.db.WithContext(ctx).Where("archived_at IS NOT NULL").Order("archived_at desc, updated_at desc").Find(&rows).Error
return rows, err
}
// Archive moves a completed subscription out of the active list without
// deleting its rule details, so users can audit completed subscriptions later.
func (r *SubscriptionRepository) Archive(ctx context.Context, id, reason string, archivedAt time.Time) error {
return r.db.WithContext(ctx).Model(&model.Subscription{}).
Where("id = ? AND archived_at IS NULL", id).
Updates(map[string]any{
"enabled": false,
"archived_at": &archivedAt,
"archive_reason": reason,
}).Error
}
// ─── Setting ─────────────────────────────────────────────────────────────────
// SettingRepository persists key/value preferences.