feat(feeds): add force run (#1243)

* feat(feeds): add force run

* fix: simplify ForceRun

* add confirmation modal

* handle errors by using the test func

* require user input to run

* make sure to reschedule next job after forcerun

* refactor modal centering with grid

* refactor: Simplify startJob and forceRun logic

- Refactor `startJob` to accept a `runImmediately` flag. This flag controls whether the job should be run immediately or scheduled for later. This change simplifies the `ForceRun` function by allowing it to call `startJob` with `runImmediately` set to `true`.

- Remove redundant checks in `ForceRun` related to feed type. These checks are handled in `startJob`.

BREAKING CHANGE: The `startJob` function now requires a second argument, `runImmediately`. This change affects all calls to `startJob`.

* fix(web) Invalidate queries after forceRun

* refactor(feeds): init and test run

---------

Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
soup 2023-11-18 21:54:53 +01:00 committed by GitHub
parent ff70a341ad
commit 2bd1a68a94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 318 additions and 38 deletions

View file

@ -37,7 +37,12 @@ type TorznabJob struct {
JobID int
}
func NewTorznabJob(feed *domain.Feed, name string, indexerIdentifier string, log zerolog.Logger, url string, client torznab.Client, repo domain.FeedRepo, cacheRepo domain.FeedCacheRepo, releaseSvc release.Service) *TorznabJob {
type FeedJob interface {
Run()
RunE(ctx context.Context) error
}
func NewTorznabJob(feed *domain.Feed, name string, indexerIdentifier string, log zerolog.Logger, url string, client torznab.Client, repo domain.FeedRepo, cacheRepo domain.FeedCacheRepo, releaseSvc release.Service) FeedJob {
return &TorznabJob{
Feed: feed,
Name: name,
@ -54,7 +59,7 @@ func NewTorznabJob(feed *domain.Feed, name string, indexerIdentifier string, log
func (j *TorznabJob) Run() {
ctx := context.Background()
if err := j.process(ctx); err != nil {
if err := j.RunE(ctx); err != nil {
j.Log.Err(err).Int("attempts", j.attempts).Msg("torznab process error")
j.errors = append(j.errors, err)
@ -64,6 +69,15 @@ func (j *TorznabJob) Run() {
j.errors = j.errors[:0]
}
func (j *TorznabJob) RunE(ctx context.Context) error {
if err := j.process(ctx); err != nil {
j.Log.Err(err).Int("attempts", j.attempts).Msg("torznab process error")
return err
}
return nil
}
func (j *TorznabJob) process(ctx context.Context) error {
// get feed
items, err := j.getFeed(ctx)