mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
60abb298b2
Closes #2612
27 lines
987 B
C#
27 lines
987 B
C#
using Dapper;
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|
{
|
|
public class CleanupOrphanedAuthorMetadata : IHousekeepingTask
|
|
{
|
|
private readonly IMainDatabase _database;
|
|
|
|
public CleanupOrphanedAuthorMetadata(IMainDatabase database)
|
|
{
|
|
_database = database;
|
|
}
|
|
|
|
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)");
|
|
}
|
|
}
|
|
}
|