Convert to 'using' declaration in Housekeeping Tasks

Closes #2612
pull/2615/head
Bogdan 2 years ago
parent c710b117ab
commit 60abb298b2

@ -14,34 +14,32 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
using var mapper = _database.OpenConnection();
if (_database.DatabaseType == DatabaseType.PostgreSQL)
{
if (_database.DatabaseType == DatabaseType.PostgreSQL)
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" = ANY (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""RelativePath""
LIKE '_:\\%'
OR ""RelativePath""
LIKE '\\%'
OR ""RelativePath""
LIKE '/%'
)");
}
else
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""RelativePath""
LIKE '_:\%'
OR ""RelativePath""
LIKE '\%'
OR ""RelativePath""
LIKE '/%'
)");
}
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" = ANY (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""RelativePath""
LIKE '_:\\%'
OR ""RelativePath""
LIKE '\\%'
OR ""RelativePath""
LIKE '/%'
)");
}
else
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""RelativePath""
LIKE '_:\%'
OR ""RelativePath""
LIKE '\%'
OR ""RelativePath""
LIKE '/%'
)");
}
}
}

@ -14,13 +14,11 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""NamingConfig""
WHERE ""Id"" NOT IN (
SELECT ""Id"" FROM ""NamingConfig""
LIMIT 1)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""NamingConfig""
WHERE ""Id"" NOT IN (
SELECT ""Id"" FROM ""NamingConfig""
LIMIT 1)");
}
}
}

@ -14,13 +14,11 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""Users""
WHERE ""Id"" NOT IN (
SELECT ""Id"" FROM ""Users""
LIMIT 1)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""Users""
WHERE ""Id"" NOT IN (
SELECT ""Id"" FROM ""Users""
LIMIT 1)");
}
}
}

@ -21,24 +21,24 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
if (_database.DatabaseType == DatabaseType.PostgreSQL)
{
mapper.Execute(@"DELETE FROM ""PendingReleases""
WHERE ""Added"" < @TwoWeeksAgo
AND ""Reason"" = ANY (@Reasons)",
new
{
TwoWeeksAgo = DateTime.UtcNow.AddDays(-14),
Reasons = new[] { (int)PendingReleaseReason.DownloadClientUnavailable, (int)PendingReleaseReason.Fallback }
});
WHERE ""Added"" < @TwoWeeksAgo
AND ""Reason"" = ANY (@Reasons)",
new
{
TwoWeeksAgo = DateTime.UtcNow.AddDays(-14),
Reasons = new[] { (int)PendingReleaseReason.DownloadClientUnavailable, (int)PendingReleaseReason.Fallback }
});
}
else
{
mapper.Execute(@"DELETE FROM ""PendingReleases""
WHERE ""Added"" < @TwoWeeksAgo
AND ""REASON"" IN @Reasons",
new
{
TwoWeeksAgo = DateTime.UtcNow.AddDays(-14),
Reasons = new[] { (int)PendingReleaseReason.DownloadClientUnavailable, (int)PendingReleaseReason.Fallback }
});
WHERE ""Added"" < @TwoWeeksAgo
AND ""REASON"" IN @Reasons",
new
{
TwoWeeksAgo = DateTime.UtcNow.AddDays(-14),
Reasons = new[] { (int)PendingReleaseReason.DownloadClientUnavailable, (int)PendingReleaseReason.Fallback }
});
}
}
}

@ -21,44 +21,38 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
private void DeleteDuplicateAuthorMetadata()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT MIN(""Id"") FROM ""MetadataFiles""
WHERE ""Type"" = 1
GROUP BY ""AuthorId"", ""Consumer""
HAVING COUNT(""AuthorId"") > 1
)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT MIN(""Id"") FROM ""MetadataFiles""
WHERE ""Type"" = 1
GROUP BY ""AuthorId"", ""Consumer""
HAVING COUNT(""AuthorId"") > 1
)");
}
private void DeleteDuplicateBookMetadata()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT MIN(""Id"") FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
GROUP BY ""BookId"", ""Consumer""
HAVING COUNT(""BookId"") > 1
)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT MIN(""Id"") FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
GROUP BY ""BookId"", ""Consumer""
HAVING COUNT(""BookId"") > 1
)");
}
private void DeleteDuplicateBookFileMetadata()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT MIN(""Id"") FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
GROUP BY ""BookFileId"", ""Consumer""
HAVING COUNT(""BookFileId"") > 1
)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT MIN(""Id"") FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
GROUP BY ""BookFileId"", ""Consumer""
HAVING COUNT(""BookFileId"") > 1
)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""AuthorMetadata""
WHERE ""Id"" IN (
SELECT ""AuthorMetadata"".""Id"" FROM ""AuthorMetadata""
LEFT OUTER JOIN ""Books"" ON ""Books"".""AuthorMetadataId"" = ""AuthorMetadata"".""Id""
LEFT OUTER JOIN ""Authors"" ON ""Authors"".""AuthorMetadataId"" = ""AuthorMetadata"".""Id""
WHERE ""Books"".""Id"" IS NULL AND ""Authors"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""AuthorMetadata""
WHERE ""Id"" IN (
SELECT ""AuthorMetadata"".""Id"" FROM ""AuthorMetadata""
LEFT OUTER JOIN ""Books"" ON ""Books"".""AuthorMetadataId"" = ""AuthorMetadata"".""Id""
LEFT OUTER JOIN ""Authors"" ON ""Authors"".""AuthorMetadataId"" = ""AuthorMetadata"".""Id""
WHERE ""Books"".""Id"" IS NULL AND ""Authors"".""Id"" IS NULL)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""Blocklist""
WHERE ""Id"" IN (
SELECT ""Blocklist"".""Id"" FROM ""Blocklist""
LEFT OUTER JOIN ""Authors""
ON ""Blocklist"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""Blocklist""
WHERE ""Id"" IN (
SELECT ""Blocklist"".""Id"" FROM ""Blocklist""
LEFT OUTER JOIN ""Authors""
ON ""Blocklist"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
}
}

@ -14,17 +14,16 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
// Unlink where track no longer exists
mapper.Execute(@"UPDATE ""BookFiles""
SET ""EditionId"" = 0
WHERE ""Id"" IN (
SELECT ""BookFiles"".""Id"" FROM ""BookFiles""
LEFT OUTER JOIN ""Editions""
ON ""BookFiles"".""EditionId"" = ""Editions"".""Id""
WHERE ""Editions"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
// Unlink where books no longer exists
mapper.Execute(@"UPDATE ""BookFiles""
SET ""EditionId"" = 0
WHERE ""Id"" IN (
SELECT ""BookFiles"".""Id"" FROM ""BookFiles""
LEFT OUTER JOIN ""Editions""
ON ""BookFiles"".""EditionId"" = ""Editions"".""Id""
WHERE ""Editions"".""Id"" IS NULL)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""Books""
WHERE ""Id"" IN (
SELECT ""Books"".""Id"" FROM ""Books""
LEFT OUTER JOIN ""Authors""
ON ""Books"".""AuthorMetadataId"" = ""Authors"".""AuthorMetadataId""
WHERE ""Authors"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""Books""
WHERE ""Id"" IN (
SELECT ""Books"".""Id"" FROM ""Books""
LEFT OUTER JOIN ""Authors""
ON ""Books"".""AuthorMetadataId"" = ""Authors"".""AuthorMetadataId""
WHERE ""Authors"".""Id"" IS NULL)");
}
}
}

@ -17,11 +17,11 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""DownloadClientStatus""
WHERE ""Id"" IN (
SELECT ""DownloadClientStatus"".""Id"" FROM ""DownloadClientStatus""
LEFT OUTER JOIN ""DownloadClients""
ON ""DownloadClientStatus"".""ProviderId"" = ""DownloadClients"".""Id""
WHERE ""DownloadClients"".""Id"" IS NULL)");
WHERE ""Id"" IN (
SELECT ""DownloadClientStatus"".""Id"" FROM ""DownloadClientStatus""
LEFT OUTER JOIN ""DownloadClients""
ON ""DownloadClientStatus"".""ProviderId"" = ""DownloadClients"".""Id""
WHERE ""DownloadClients"".""Id"" IS NULL)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""Editions""
WHERE ""Id"" IN (
SELECT ""Editions"".""Id"" FROM ""Editions""
LEFT OUTER JOIN ""Books""
ON ""Editions"".""BookId"" = ""Books"".""Id""
WHERE ""Books"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""Editions""
WHERE ""Id"" IN (
SELECT ""Editions"".""Id"" FROM ""Editions""
LEFT OUTER JOIN ""Books""
ON ""Editions"".""BookId"" = ""Books"".""Id""
WHERE ""Books"".""Id"" IS NULL)");
}
}
}

@ -20,28 +20,24 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
private void CleanupOrphanedByAuthor()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""History""
WHERE ""Id"" IN (
SELECT ""History"".""Id"" FROM ""History""
LEFT OUTER JOIN ""Authors""
ON ""History"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""History""
WHERE ""Id"" IN (
SELECT ""History"".""Id"" FROM ""History""
LEFT OUTER JOIN ""Authors""
ON ""History"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
private void CleanupOrphanedByBook()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""History""
WHERE ""Id"" IN (
SELECT ""History"".""Id"" FROM ""History""
LEFT OUTER JOIN ""Books""
ON ""History"".""BookId"" = ""Books"".""Id""
WHERE ""Books"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""History""
WHERE ""Id"" IN (
SELECT ""History"".""Id"" FROM ""History""
LEFT OUTER JOIN ""Books""
ON ""History"".""BookId"" = ""Books"".""Id""
WHERE ""Books"".""Id"" IS NULL)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""ImportListStatus""
WHERE ""Id"" IN (
SELECT ""ImportListStatus"".""Id"" FROM ""ImportListStatus""
LEFT OUTER JOIN ""ImportLists""
ON ""ImportListStatus"".""ProviderId"" = ""ImportLists"".""Id""
WHERE ""ImportLists"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""ImportListStatus""
WHERE ""Id"" IN (
SELECT ""ImportListStatus"".""Id"" FROM ""ImportListStatus""
LEFT OUTER JOIN ""ImportLists""
ON ""ImportListStatus"".""ProviderId"" = ""ImportLists"".""Id""
WHERE ""ImportLists"".""Id"" IS NULL)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""IndexerStatus""
WHERE ""Id"" IN (
SELECT ""IndexerStatus"".""Id"" FROM ""IndexerStatus""
LEFT OUTER JOIN ""Indexers""
ON ""IndexerStatus"".""ProviderId"" = ""Indexers"".""Id""
WHERE ""Indexers"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""IndexerStatus""
WHERE ""Id"" IN (
SELECT ""IndexerStatus"".""Id"" FROM ""IndexerStatus""
LEFT OUTER JOIN ""Indexers""
ON ""IndexerStatus"".""ProviderId"" = ""Indexers"".""Id""
WHERE ""Indexers"".""Id"" IS NULL)");
}
}
}

@ -23,67 +23,57 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
private void DeleteOrphanedByAuthor()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""MetadataFiles"".""Id"" FROM ""MetadataFiles""
LEFT OUTER JOIN ""Authors""
ON ""MetadataFiles"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""MetadataFiles"".""Id"" FROM ""MetadataFiles""
LEFT OUTER JOIN ""Authors""
ON ""MetadataFiles"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
private void DeleteOrphanedByBook()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""MetadataFiles"".""Id"" FROM ""MetadataFiles""
LEFT OUTER JOIN ""Books""
ON ""MetadataFiles"".""BookId"" = ""Books"".""Id""
WHERE ""MetadataFiles"".""BookId"" > 0
AND ""Books"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""MetadataFiles"".""Id"" FROM ""MetadataFiles""
LEFT OUTER JOIN ""Books""
ON ""MetadataFiles"".""BookId"" = ""Books"".""Id""
WHERE ""MetadataFiles"".""BookId"" > 0
AND ""Books"".""Id"" IS NULL)");
}
private void DeleteOrphanedByTrackFile()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""MetadataFiles"".""Id"" FROM ""MetadataFiles""
LEFT OUTER JOIN ""BookFiles""
ON ""MetadataFiles"".""BookFileId"" = ""BookFiles"".""Id""
WHERE ""MetadataFiles"".""BookFileId"" > 0
AND ""BookFiles"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""MetadataFiles"".""Id"" FROM ""MetadataFiles""
LEFT OUTER JOIN ""BookFiles""
ON ""MetadataFiles"".""BookFileId"" = ""BookFiles"".""Id""
WHERE ""MetadataFiles"".""BookFileId"" > 0
AND ""BookFiles"".""Id"" IS NULL)");
}
private void DeleteWhereBookIdIsZero()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
AND ""BookId"" = 0)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
AND ""BookId"" = 0)");
}
private void DeleteWhereTrackFileIsZero()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
AND ""BookFileId"" = 0)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""MetadataFiles""
WHERE ""Id"" IN (
SELECT ""Id"" FROM ""MetadataFiles""
WHERE ""Type"" IN (2, 4)
AND ""BookFileId"" = 0)");
}
}
}

@ -14,15 +14,13 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""PendingReleases""
WHERE ""Id"" IN (
SELECT ""PendingReleases"".""Id"" FROM ""PendingReleases""
LEFT OUTER JOIN ""Authors""
ON ""PendingReleases"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""PendingReleases""
WHERE ""Id"" IN (
SELECT ""PendingReleases"".""Id"" FROM ""PendingReleases""
LEFT OUTER JOIN ""Authors""
ON ""PendingReleases"".""AuthorId"" = ""Authors"".""Id""
WHERE ""Authors"".""Id"" IS NULL)");
}
}
}

@ -14,22 +14,20 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"DELETE FROM ""SeriesBookLink""
WHERE ""Id"" IN (
SELECT ""SeriesBookLink"".""Id"" FROM ""SeriesBookLink""
LEFT OUTER JOIN ""Books""
ON ""SeriesBookLink"".""BookId"" = ""Books"".""Id""
WHERE ""Books"".""Id"" IS NULL)");
using var mapper = _database.OpenConnection();
mapper.Execute(@"DELETE FROM ""SeriesBookLink""
WHERE ""Id"" IN (
SELECT ""SeriesBookLink"".""Id"" FROM ""SeriesBookLink""
LEFT OUTER JOIN ""Books""
ON ""SeriesBookLink"".""BookId"" = ""Books"".""Id""
WHERE ""Books"".""Id"" IS NULL)");
mapper.Execute(@"DELETE FROM ""SeriesBookLink""
WHERE ""Id"" IN (
SELECT ""SeriesBookLink"".""Id"" FROM ""SeriesBookLink""
LEFT OUTER JOIN ""Series""
ON ""SeriesBookLink"".""SeriesId"" = ""Series"".""Id""
WHERE ""Series"".""Id"" IS NULL)");
}
mapper.Execute(@"DELETE FROM ""SeriesBookLink""
WHERE ""Id"" IN (
SELECT ""SeriesBookLink"".""Id"" FROM ""SeriesBookLink""
LEFT OUTER JOIN ""Series""
ON ""SeriesBookLink"".""SeriesId"" = ""Series"".""Id""
WHERE ""Series"".""Id"" IS NULL)");
}
}
}

@ -18,31 +18,29 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
public void Clean()
{
using (var mapper = _database.OpenConnection())
using var mapper = _database.OpenConnection();
var usedTags = new[] { "Authors", "Notifications", "DelayProfiles", "ReleaseProfiles", "ImportLists", "Indexers" }
.SelectMany(v => GetUsedTags(v, mapper))
.Distinct()
.ToArray();
if (usedTags.Any())
{
var usedTags = new[] { "Authors", "Notifications", "DelayProfiles", "ReleaseProfiles", "ImportLists", "Indexers" }
.SelectMany(v => GetUsedTags(v, mapper))
.Distinct()
.ToArray();
var usedTagsList = usedTags.Select(d => d.ToString()).Join(",");
if (usedTags.Any())
if (_database.DatabaseType == DatabaseType.PostgreSQL)
{
var usedTagsList = usedTags.Select(d => d.ToString()).Join(",");
if (_database.DatabaseType == DatabaseType.PostgreSQL)
{
mapper.Execute($"DELETE FROM \"Tags\" WHERE NOT \"Id\" = ANY (\'{{{usedTagsList}}}\'::int[])");
}
else
{
mapper.Execute($"DELETE FROM \"Tags\" WHERE NOT \"Id\" IN ({usedTagsList})");
}
mapper.Execute($"DELETE FROM \"Tags\" WHERE NOT \"Id\" = ANY (\'{{{usedTagsList}}}\'::int[])");
}
else
{
mapper.Execute("DELETE FROM \"Tags\"");
mapper.Execute($"DELETE FROM \"Tags\" WHERE NOT \"Id\" IN ({usedTagsList})");
}
}
else
{
mapper.Execute("DELETE FROM \"Tags\"");
}
}
private int[] GetUsedTags(string table, IDbConnection mapper)

@ -24,13 +24,11 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
_logger.Debug("Not running scheduled task last execution cleanup during debug");
}
using (var mapper = _database.OpenConnection())
{
mapper.Execute(@"UPDATE ""ScheduledTasks""
SET ""LastExecution"" = @time
WHERE ""LastExecution"" > @time",
new { time = DateTime.UtcNow });
}
using var mapper = _database.OpenConnection();
mapper.Execute(@"UPDATE ""ScheduledTasks""
SET ""LastExecution"" = @time
WHERE ""LastExecution"" > @time",
new { time = DateTime.UtcNow });
}
}
}

Loading…
Cancel
Save