mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
fix bug in adding SnapshotRules
This commit is contained in:
parent
e97e36f6ef
commit
270950db2c
3 changed files with 14 additions and 2 deletions
|
|
@ -9,5 +9,15 @@ public static void AddIfNotNullOrEmpty(this ICollection<string> set, string item
|
|||
if (!string.IsNullOrEmpty(item))
|
||||
set.Add(item);
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/a/26360010/2343739
|
||||
public static void AddRange<T>(this ICollection<T> destination, IEnumerable<T> source)
|
||||
{
|
||||
if (destination is List<T> list)
|
||||
list.AddRange(source);
|
||||
else
|
||||
foreach (var item in source)
|
||||
destination.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
using FilterLists.Data;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Extensions;
|
||||
|
||||
namespace FilterLists.Services.Snapshot
|
||||
{
|
||||
|
|
@ -38,7 +39,7 @@ private IQueryable<Rule> GetOrCreateRules()
|
|||
private void CreateSnapRules(IQueryable<Rule> rules)
|
||||
{
|
||||
var snapRules = rules.Select(r => new SnapshotRule {Rule = r}).ToList();
|
||||
snapEntity.SnapshotRules = snapRules;
|
||||
snapEntity.SnapshotRules.AddRange(snapRules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Extensions;
|
||||
using FilterLists.Services.Snapshot.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
|
@ -39,7 +40,7 @@ public Snapshot(BatchSizeService batchSizeService, FilterListsDbContext dbContex
|
|||
this.dbContext = dbContext;
|
||||
List = list;
|
||||
ListUrl = list.ViewUrl;
|
||||
SnapEntity = new Data.Entities.Snapshot {FilterListId = list.Id};
|
||||
SnapEntity = new Data.Entities.Snapshot {FilterListId = list.Id, SnapshotRules = new List<SnapshotRule>()};
|
||||
this.uaString = uaString;
|
||||
telemetryClient = new TelemetryClient();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue