mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-15 08:55:37 -05:00
feat(library): filter the drawing library by thickness, size, holes, date and customer
Finding a part on the nest server meant scrolling 40k drawings: the library could only match an exact thickness or customer and knew nothing about a drawing's size or holes. The library browser gets a Filter dialog with inclusive ranges, and the query API takes them. The server never parses packages and stays off IO, so the server worker now measures each package beside its nest jobs (bounding sides, net area, closed cutouts inside the outline) and stores the summary keyed by package hash (schema v19). Identical geometry is measured once, an unreadable package is recorded once instead of retried forever, and size or hole limits match only measured drawings. Thickness ranges compare in inches across units and keep the library's rule that a drawing saved without a thickness suits any. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1382d00496
commit
b9fc618a50
38 files changed
+2170
-43
No files matched your search
@@ -246,7 +246,7 @@ public sealed class RemoteDrawingLibrary : NestServerClient, IDrawingLibraryStor
|
||||
.Append("&order=").Append(query.Descending ? "desc" : "asc")
|
||||
.Append("&offset=").Append(query.Offset.ToString(CultureInfo.InvariantCulture))
|
||||
.Append("&limit=").Append(query.Limit.ToString(CultureInfo.InvariantCulture));
|
||||
AppendFilter(text, "customer", query.Customer);
|
||||
AppendFilter(text, "customer", query.EffectiveCustomer);
|
||||
AppendFilter(text, "materialName", query.MaterialName);
|
||||
AppendFilter(text, "materialGrade", query.MaterialGrade);
|
||||
if (query.Thickness is { } thickness)
|
||||
@@ -257,9 +257,35 @@ public sealed class RemoteDrawingLibrary : NestServerClient, IDrawingLibraryStor
|
||||
text.Append("&cutFirst=").Append(cutFirst ? "true" : "false");
|
||||
if (query.IncludeArchived)
|
||||
text.Append("&includeArchived=true");
|
||||
AppendRanges(text, query.Filter);
|
||||
return text.ToString();
|
||||
}
|
||||
|
||||
// Only the limits that are set, so an unfiltered query stays readable by older servers.
|
||||
private static void AppendRanges(StringBuilder text, DrawingLibraryFilter filter)
|
||||
{
|
||||
AppendNumber(text, "minThickness", filter.MinThickness);
|
||||
AppendNumber(text, "maxThickness", filter.MaxThickness);
|
||||
if (!filter.IncludeBlankThickness)
|
||||
text.Append("&includeBlankThickness=false");
|
||||
AppendNumber(text, "minLength", filter.MinLength);
|
||||
AppendNumber(text, "maxLength", filter.MaxLength);
|
||||
AppendNumber(text, "minWidth", filter.MinWidth);
|
||||
AppendNumber(text, "maxWidth", filter.MaxWidth);
|
||||
AppendNumber(text, "minHoles", filter.MinHoles);
|
||||
AppendNumber(text, "maxHoles", filter.MaxHoles);
|
||||
if (filter.SavedFrom is { } from)
|
||||
text.Append("&savedFrom=").Append(from.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
|
||||
if (filter.SavedTo is { } to)
|
||||
text.Append("&savedTo=").Append(to.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
private static void AppendNumber(StringBuilder text, string key, double? value)
|
||||
{
|
||||
if (value is { } number)
|
||||
text.Append('&').Append(key).Append('=').Append(number.ToString("R", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
private static void AppendFilter(StringBuilder text, string key, string? value)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
|
||||
Reference in new issue
Block a user