mirror of https://github.com/Sonarr/Sonarr
parent
3fb5f65f08
commit
2f6409226a
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Marr.Data;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
|
@ -19,19 +20,19 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|||
{
|
||||
var mapper = _database.GetDataMapper();
|
||||
|
||||
var usedTags = new[] { "Series", "Notifications", "DelayProfiles", "ReleaseProfiles" }
|
||||
var usedTags = new[] { "Series", "Notifications", "DelayProfiles", "ReleaseProfiles", "ImportLists", "Indexers" }
|
||||
.SelectMany(v => GetUsedTags(v, mapper))
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
.ToList();
|
||||
|
||||
var usedTagsList = string.Join(",", usedTags.Select(d => d.ToString()).ToArray());
|
||||
var usedTagsList = usedTags.Select(d => d.ToString()).Join(",");
|
||||
|
||||
mapper.ExecuteNonQuery($"DELETE FROM Tags WHERE NOT Id IN ({usedTagsList})");
|
||||
}
|
||||
|
||||
private int[] GetUsedTags(string table, IDataMapper mapper)
|
||||
{
|
||||
return mapper.ExecuteReader($"SELECT DISTINCT Tags FROM {table} WHERE NOT Tags = '[]'", reader => reader.GetString(0))
|
||||
return mapper.ExecuteReader($"SELECT DISTINCT Tags FROM {table} WHERE NOT Tags = '[]' AND NOT Tags IS NULL", reader => reader.GetString(0))
|
||||
.SelectMany(Json.Deserialize<List<int>>)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
|
Loading…
Reference in New Issue