Lidarr/NzbDrone.Core/Jobs/JobRepository.cs

36 lines
984 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Datastore;
2013-03-05 05:37:33 +00:00
namespace NzbDrone.Core.Jobs
{
public interface IScheduledTaskRepository : IBasicRepository<ScheduledTask>
{
IList<ScheduledTask> GetPendingJobs();
ScheduledTask GetDefinition(Type type);
}
public class ScheduledTaskRepository : BasicRepository<ScheduledTask>, IScheduledTaskRepository
{
public ScheduledTaskRepository(IDatabase database, IMessageAggregator messageAggregator)
2013-05-05 21:24:33 +00:00
: base(database, messageAggregator)
{
}
public ScheduledTask GetDefinition(Type type)
{
2013-05-07 00:39:33 +00:00
return Query.Single(c => c.Name == type.FullName);
}
public IList<ScheduledTask> GetPendingJobs()
{
2013-05-07 00:39:33 +00:00
return Query.Where(c => c.Interval != 0).ToList().Where(c => c.LastExecution < DateTime.Now.AddMinutes(-c.Interval)).ToList();
}
}
2013-03-25 03:51:32 +00:00
}