2020-08-18 20:11:44 +00:00
|
|
|
|
using Dapper;
|
|
|
|
|
using NzbDrone.Core.Datastore;
|
2014-06-08 08:22:55 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|
|
|
|
{
|
|
|
|
|
public class CleanupOrphanedPendingReleases : IHousekeepingTask
|
|
|
|
|
{
|
2015-05-03 19:46:21 +00:00
|
|
|
|
private readonly IMainDatabase _database;
|
2014-06-08 08:22:55 +00:00
|
|
|
|
|
2015-05-03 19:46:21 +00:00
|
|
|
|
public CleanupOrphanedPendingReleases(IMainDatabase database)
|
2014-06-08 08:22:55 +00:00
|
|
|
|
{
|
|
|
|
|
_database = database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clean()
|
|
|
|
|
{
|
2020-08-18 20:11:44 +00:00
|
|
|
|
using (var mapper = _database.OpenConnection())
|
|
|
|
|
{
|
2022-01-26 00:08:27 +00:00
|
|
|
|
mapper.Execute(@"DELETE FROM ""PendingReleases""
|
|
|
|
|
WHERE ""Id"" IN (
|
|
|
|
|
SELECT ""PendingReleases"".""Id"" FROM ""PendingReleases""
|
|
|
|
|
LEFT OUTER JOIN ""Artists""
|
|
|
|
|
ON ""PendingReleases"".""ArtistId"" = ""Artists"".""Id""
|
|
|
|
|
WHERE ""Artists"".""Id"" IS NULL)");
|
2020-08-18 20:11:44 +00:00
|
|
|
|
}
|
2014-06-08 08:22:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|