Skip to content

Commit 51fb5b3

Browse files
committed
added missing grouping clone
1 parent a15c05d commit 51fb5b3

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/Tetrifact.Core/PruneBracketProcess.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Newtonsoft.Json.Bson;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43

54
namespace Tetrifact.Core
@@ -9,8 +8,8 @@ public class PruneBracketProcess : PruneBracket
98
public IList<Manifest> Keep { get ; set; } = new List<Manifest>();
109

1110
public IList<Manifest> Prune { get; set; } = new List<Manifest>();
12-
13-
public TimeSpan Coverage { get; set; }
11+
12+
public int Found { get; set; }
1413

1514
/// <summary>
1615
/// Days back in time from Now that bracket covers. Calculated at start of a given prune run.
@@ -36,7 +35,8 @@ public static PruneBracketProcess FromPruneBracket(PruneBracket pruneBracket)
3635
return new PruneBracketProcess
3736
{
3837
Amount = pruneBracket.Amount,
39-
Days = pruneBracket.Days
38+
Days = pruneBracket.Days,
39+
Grouping = pruneBracket.Grouping
4040
};
4141
}
4242
}

src/Tetrifact.Core/PruneService.cs

+14-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5-
5+
using System.Text;
6+
67
namespace Tetrifact.Core
78
{
89
public class PruneService : IPruneService
@@ -17,10 +18,10 @@ public class PruneService : IPruneService
1718

1819
ITimeProvideer _timeprovider;
1920

20-
IProcessLockManager _processLock;
21+
IProcessLockManager _processLock;
2122

2223
#endregion
23-
24+
2425
#region CTORS
2526

2627
public PruneService(ISettings settings, IProcessLockManager processLock, ITimeProvideer timeprovider, IIndexReadService indexReader, ILogger<IPruneService> log)
@@ -137,6 +138,8 @@ public PrunePlan GeneratePrunePlan()
137138
continue;
138139
}
139140

141+
matchingBracket.Found++;
142+
140143
// try to find reasons to keep package
141144

142145
// packages can be tagged to never be deleted. This ignores keep count, but will push out packages that are not tagged
@@ -162,9 +165,9 @@ public PrunePlan GeneratePrunePlan()
162165
{
163166
int code = manifest.CreatedUtc.ToDayCode();
164167
int kept = matchingBracket.Keep.Count(m => m.CreatedUtc.ToDayCode() == code);
165-
if (kept < matchingBracket.Amount)
168+
if (kept < matchingBracket.Amount)
166169
{
167-
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket.Days} had {matchingBracket.Amount - kept} slots left for day {code}.");
170+
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket}::day {code} had {matchingBracket.Amount - kept} slots left.");
168171
matchingBracket.Keep.Add(manifest);
169172
continue;
170173
}
@@ -177,7 +180,7 @@ public PrunePlan GeneratePrunePlan()
177180
int kept = matchingBracket.Keep.Count(m => m.CreatedUtc.ToWeekCode() == code);
178181
if (kept < matchingBracket.Amount)
179182
{
180-
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket.Days} had {matchingBracket.Amount - kept} slots left for week {code}.");
183+
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket}::week {code} had {matchingBracket.Amount - kept} slots left.");
181184
matchingBracket.Keep.Add(manifest);
182185
continue;
183186
}
@@ -190,7 +193,7 @@ public PrunePlan GeneratePrunePlan()
190193
int kept = matchingBracket.Keep.Count(m => m.CreatedUtc.ToMonthCode() == code);
191194
if (kept < matchingBracket.Amount)
192195
{
193-
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket.Days} had {matchingBracket.Amount - kept} slots left for month {code}.");
196+
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket}::month {code} had {matchingBracket.Amount - kept} slots left.");
194197
matchingBracket.Keep.Add(manifest);
195198
continue;
196199
}
@@ -203,7 +206,7 @@ public PrunePlan GeneratePrunePlan()
203206
int kept = matchingBracket.Keep.Count(m => m.CreatedUtc.Year == code);
204207
if (kept < matchingBracket.Amount)
205208
{
206-
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket.Days} had {matchingBracket.Amount - kept} slots left for year {code}.");
209+
report.Add($"Package \"{packageId}\" marked for keep, bracket {matchingBracket}::year {code} had {matchingBracket.Amount - kept} slots left.");
207210
matchingBracket.Keep.Add(manifest);
208211
continue;
209212
}
@@ -229,6 +232,7 @@ public PrunePlan GeneratePrunePlan()
229232
totalKeep += p.Keep.Count;
230233
totalPrune += p.Prune.Count;
231234
report.Add($"Bracket {p}.");
235+
report.Add($"Found {p.Found} packages falling in this date range.");
232236
report.Add($"Keeping {p.Keep.Count}{FlattenList(p.Keep.Select(p => p.Id))}.");
233237
report.Add($"Pruning {p.Prune.Count}{FlattenList(p.Prune.Select(p => p.Id))}.");
234238
report.Add(string.Empty);
@@ -257,8 +261,8 @@ private string FlattenList(IEnumerable<object> packages)
257261
return string.Empty;
258262

259263
return $" ({string.Join(",", packages)})";
260-
}
261-
264+
}
265+
262266
#endregion
263267
}
264268
}

0 commit comments

Comments
 (0)