Plantings backend: plop CRUD, derived counts, removed_at (#14)
Build image / build-and-push (push) Successful in 7s

Co-authored-by: Steve Dudenhoeffer <[email protected]>
This commit was merged in pull request #33.
This commit is contained in:
2026-07-19 02:41:22 +00:00
committed by steve
parent e4505ed9a7
commit f4e5dab98c
10 changed files with 990 additions and 9 deletions
+11 -2
View File
@@ -69,8 +69,8 @@ type ObjectPatch struct {
}
// FullGarden is the one-shot editor payload: the garden plus everything drawn in
// it. Plantings/Plants stay empty until #14 populates plantings; the shape is
// fixed now so the frontend types against it once.
// it — objects, active plantings (each with its DerivedCount filled in), and the
// plants those plantings reference.
type FullGarden struct {
Garden *domain.Garden `json:"garden"`
Objects []domain.GardenObject `json:"objects"`
@@ -176,6 +176,15 @@ func (s *Service) GardenFull(ctx context.Context, actorID, gardenID int64) (*Ful
if err != nil {
return nil, err
}
// Fill each plop's DerivedCount from its plant's spacing (referenced plants
// are already loaded, so this is a map lookup rather than N queries).
spacing := make(map[int64]float64, len(plants))
for _, pl := range plants {
spacing[pl.ID] = pl.SpacingCM
}
for i := range plantings {
plantings[i].DerivedCount = derivedCount(plantings[i].RadiusCM, spacing[plantings[i].PlantID])
}
return &FullGarden{Garden: g, Objects: objects, Plantings: plantings, Plants: plants}, nil
}