feat(deploy): TrueNAS Custom-App + Auto-Deploy, plus aufgelaufene Arbeit
Some checks failed
CI / Backend Tests (.NET) (push) Successful in 1m11s
CI / Frontend Tests (Node/Vite) (push) Failing after 4m59s
CI / Docker Build & Push (push) Has been skipped
CI / Deploy auf TrueNAS (Custom App) (push) Has been skipped

Deployment:
- custom-app.compose.yaml: self-contained Compose fuer TrueNAS "Custom App"
  (absolute Host-Bind-Pfade, postgres:18, pull_policy always, Port 8090)
- scripts/truenas-deploy.sh: Host-Skript create/redeploy via midclt (App
  bleibt unter Apps sichtbar) inkl. Image-Pull + Health-Check
- ci.yml Deploy-Job: laeuft auf ubuntu-latest-Runner, kopiert Deploy-Dateien
  per SSH auf den NAS-Host und triggert truenas-deploy.sh (statt runs-on goldeye)
- compose.yaml/.env.example: postgres:18 (Locale-Match zur Quell-DB), Port 8090
- .gitignore: .agents/, tools/rag/, deploy/truenas/.env (Secrets/Scratch)

Aufgelaufene Feature-Arbeit (verified/Freeze, Migrationen, Import-Triage):
- GerbilOverride/VerifiedGerbil-Endpoints + GerbilSnapshotService + Tests
- EF-Migrationen (ShowInChronicle, Stillborn, BirthOrder, ManualFlag, DSGVO)
- Frontend VerifizierteTierePage + verified-API + e2e-Spec
- diverse Import-/Triage-Skripte und -Tests

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-19 09:19:11 +02:00
parent 84365bba7f
commit 45b8533f18
93 changed files with 20477 additions and 432 deletions

View File

@@ -1,5 +1,6 @@
using GerbilManagerWebAPI.Common;
using GerbilManagerWebAPI.Dtos;
using GerbilManagerWebAPI.Import;
using GerbilManagerWebAPI.Models;
using GerbilManagerWebAPI.Services;
using Gridify;
@@ -61,7 +62,9 @@ namespace GerbilManagerWebAPI.Endpoints
if (string.IsNullOrWhiteSpace(input.Name))
return TypedResults.ValidationProblem(new Dictionary<string, string[]> { ["name"] = ["Name is required."] });
var g = new Gerbil { Id = Guid.NewGuid(), Name = input.Name! };
// Manually created in the UI → IsManual=true, so the import re-ingest never wipes or
// overwrites this animal (and its sub-records).
var g = new Gerbil { Id = Guid.NewGuid(), Name = input.Name!, IsManual = true };
Apply(g, input, isCreate: true);
db.Gerbils.Add(g);
await db.SaveChangesAsync();
@@ -73,8 +76,17 @@ namespace GerbilManagerWebAPI.Endpoints
{
var g = await db.Gerbils.FirstOrDefaultAsync(x => x.Id == id);
if (g is null) return TypedResults.NotFound();
// Capture the own-field values BEFORE the edit so manual changes to an IMPORTED animal
// can be pinned per-field (survive the next ingest). Manual animals need no override —
// they survive the ingest wholesale.
var before = GerbilSnapshotService.BuildFreezeObject(g);
Apply(g, input, isCreate: false);
await db.SaveChangesAsync();
if (!g.IsManual)
await RecordEditOverrideAsync(db, g, before);
return TypedResults.NoContent();
});
@@ -133,11 +145,47 @@ namespace GerbilManagerWebAPI.Endpoints
GerbilStatusService.Apply(g, DateOnly.FromDateTime(DateTime.UtcNow));
}
// EDIT PROTECTION: after a manual edit to an IMPORTED animal, pin the change so the next
// ingest can't overwrite it. A VERIFIED animal keeps its certification and its whole golden
// is refreshed to the edited state (Frage 5). An unverified animal gets/updates a "geschützt"
// override carrying ONLY the changed fields (per-field) — untouched fields keep receiving
// import improvements. Called after the edit is already persisted.
private static async Task RecordEditOverrideAsync(ApplicationContext db, Gerbil g, System.Text.Json.Nodes.JsonObject before)
{
var ov = await db.GerbilOverrides.FirstOrDefaultAsync(o => o.GerbilId == g.Id);
if (ov is { IsVerified: true })
{
ov.EntityName = g.Name;
ov.OverrideJson = GerbilSnapshotService.BuildFreezeJson(g);
var snap = await GerbilSnapshotService.BuildSnapshotAsync(db, g.Id);
if (snap is not null) ov.SnapshotJson = GerbilSnapshotService.SerializeSnapshot(snap);
ov.LastImportSnapshotJson = null;
ov.LastImportDiffJson = null;
ov.UpdatedAt = DateTimeOffset.UtcNow;
await db.SaveChangesAsync();
return;
}
var after = GerbilSnapshotService.BuildFreezeObject(g);
var changed = GerbilSnapshotService.ChangedFields(before, after);
if (changed.Count == 0) return;
if (ov is null)
{
ov = new GerbilOverride { Id = Guid.NewGuid(), GerbilId = g.Id, IsVerified = false, OverrideJson = "{}" };
db.GerbilOverrides.Add(ov);
}
ov.EntityName = g.Name;
ov.OverrideJson = GerbilSnapshotService.MergeOverrideJson(ov.OverrideJson, changed);
ov.UpdatedAt = DateTimeOffset.UtcNow;
await db.SaveChangesAsync();
}
internal static GerbilDto ToDto(Gerbil g, string? profilePhotoUrl = null) => new(
g.Id, g.Name, g.Gender, g.Status, g.LitterId, g.OriginContactId, g.ReceiverContactId,
g.EnclosureId, g.ColorVarietyId, g.DateOfBirth, g.DateOfDeath, g.CauseOfDeath,
g.GoHomeDate, g.Genotype, g.SpottingType, g.Notes, g.ImportSource, g.ExternalRef, g.OriginBreeder,
g.CharacterTraits, g.CharacterNote, g.IsDeaf, g.IsResident, profilePhotoUrl, g.IsCastrated,
g.Provenance);
g.Provenance, g.BirthOrder);
}
}