feat(feeds): view latest RSS and Torznab feed (#609)

feat(feeds): view latest run
This commit is contained in:
ze0s 2023-01-02 23:00:11 +01:00 committed by GitHub
parent 5972d421d8
commit fd67a7b24e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 205 additions and 47 deletions

View file

@ -16,6 +16,7 @@ type Service interface {
Stop()
AddJob(job cron.Job, interval time.Duration, identifier string) (int, error)
RemoveJobByIdentifier(id string) error
GetNextRun(id string) (time.Time, error)
}
type service struct {
@ -110,6 +111,30 @@ func (s *service) RemoveJobByIdentifier(id string) error {
return nil
}
func (s *service) GetNextRun(id string) (time.Time, error) {
entry := s.getEntryById(id)
if !entry.Valid() {
return time.Time{}, nil
}
s.log.Debug().Msgf("scheduler.GetNextRun: %s next run: %s", id, entry.Next)
return entry.Next, nil
}
func (s *service) getEntryById(id string) cron.Entry {
s.m.Lock()
defer s.m.Unlock()
v, ok := s.jobs[id]
if !ok {
return cron.Entry{}
}
return s.cron.Entry(v)
}
type GenericJob struct {
Name string
Log zerolog.Logger