feat(server): allocate nest names from one yearly server sequence

File > New restarted its counter every day while names only carry the
year, so the first nest of each day was always N26-223, and each PC kept
its own counter. In Database mode the nest server now hands out the
year's next number (POST /api/nest-names/next, nest_sequences table,
schema v6), staying above every stored generated name so offline or
pre-existing names are never reissued. The per-PC counter remains the
fallback when the server is unreachable or older, resets per year, and
is raised past each server allocation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-10-19 11:09:07 -04:00
1 parent d35178c3b5
commit 3bc71a7e87
13 files changed
+329 -50

No files matched your search

+9
View File
@@ -49,6 +49,15 @@ app.MapGet("/api/nests/{id:guid}", (Guid id, NestDatabase db) =>
app.MapGet("/api/nests/{id:guid}/file", (Guid id, NestDatabase db) =>
db.GetFile(id) is { } file ? Results.File(file, "application/zip", $"{id}.nest") : Results.NotFound());
// Next generated nest name for a year; one counter per year shared by every client.
app.MapPost("/api/nest-names/next", (int year, NestDatabase db) =>
{
if (year is < NestNames.MinYear or > NestNames.MaxYear)
return Results.BadRequest($"year must be between {NestNames.MinYear} and {NestNames.MaxYear}.");
var number = db.AllocateNestNumber(year);
return Results.Ok(new NestNameAllocation { Year = year, Number = number, Name = NestNames.Format(year, number) });
});
// POST/PUT multipart: "metadata" JSON part + "file" part (the .nest archive).
app.MapPost("/api/nests", async (HttpContext http, NestDatabase db) =>
{