mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
feat(feeds): view latest RSS and Torznab feed (#609)
feat(feeds): view latest run
This commit is contained in:
parent
5972d421d8
commit
fd67a7b24e
11 changed files with 205 additions and 47 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue