1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

simplification of cleanup unused tags

This commit is contained in:
Robin Dadswell 2021-10-19 21:51:15 +01:00
parent c93c87de30
commit 4299799967

View File

@ -18,17 +18,16 @@ public CleanupUnusedTags(IMainDatabase database)
public void Clean() public void Clean()
{ {
using (var mapper = _database.OpenConnection()) var mapper = _database.OpenConnection();
{
var usedTags = new[] { "Movies", "Notifications", "DelayProfiles", "Restrictions", "ImportLists", "Indexers" }
.SelectMany(v => GetUsedTags(v, mapper))
.Distinct()
.ToList();
var usedTagsList = usedTags.Select(d => d.ToString()).Join(","); var usedTags = new[] { "Movies", "Notifications", "DelayProfiles", "Restrictions", "ImportLists", "Indexers" }
.SelectMany(v => GetUsedTags(v, mapper))
.Distinct()
.ToList();
mapper.Execute($"DELETE FROM Tags WHERE NOT Id IN ({usedTagsList})"); var usedTagsList = usedTags.Select(d => d.ToString()).Join(",");
}
mapper.Execute($"DELETE FROM Tags WHERE NOT Id IN ({usedTagsList})");
} }
private int[] GetUsedTags(string table, IDbConnection mapper) private int[] GetUsedTags(string table, IDbConnection mapper)