mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-02 04:16:38 +08:00
Unify organize ingest pipeline
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user