Support species height and width ranges
CI / test (push) Failing after 3m6s

This commit is contained in:
2026-09-16 20:21:41 +02:00
parent 87809b2344
commit ef608551ad
14 changed files with 271 additions and 69 deletions
+27 -1
View File
@@ -25,6 +25,14 @@ type speciesInput struct {
WinterProtection *string `json:"winter_protection"`
SpacingCM *int `json:"spacing_cm"`
HeightCM *int `json:"height_cm"`
HeightCMFrom *int `json:"height_cm_from"`
HeightCMTo *int `json:"height_cm_to"`
WidthCMFrom *int `json:"width_cm_from"`
WidthCMTo *int `json:"width_cm_to"`
ClearHeightCMFrom bool `json:"clear_height_cm_from"`
ClearHeightCMTo bool `json:"clear_height_cm_to"`
ClearWidthCMFrom bool `json:"clear_width_cm_from"`
ClearWidthCMTo bool `json:"clear_width_cm_to"`
SowMonthFrom *int `json:"sow_month_from"`
SowDayFrom *int `json:"sow_day_from"`
ClearSowDayFrom bool `json:"clear_sow_day_from"`
@@ -70,7 +78,19 @@ func (input speciesInput) apply(species *storage.Species) {
assignStringPointer(input.SoilReaction, &species.SoilReaction)
assignStringPointer(input.WinterProtection, &species.WinterProtection)
assignIntPointer(input.SpacingCM, &species.SpacingCM)
assignIntPointer(input.HeightCM, &species.HeightCM)
assignIntPointer(input.HeightCMFrom, &species.HeightCMFrom)
if input.HeightCMTo != nil {
assignIntPointer(input.HeightCMTo, &species.HeightCMTo)
} else {
assignIntPointer(input.HeightCM, &species.HeightCMTo)
}
assignIntPointer(input.WidthCMFrom, &species.WidthCMFrom)
assignIntPointer(input.WidthCMTo, &species.WidthCMTo)
clearIntPointer(input.ClearHeightCMFrom, &species.HeightCMFrom)
clearIntPointer(input.ClearHeightCMTo, &species.HeightCMTo)
clearIntPointer(input.ClearWidthCMFrom, &species.WidthCMFrom)
clearIntPointer(input.ClearWidthCMTo, &species.WidthCMTo)
species.HeightCM = species.HeightCMTo
assignIntPointer(input.SowMonthFrom, &species.SowMonthFrom)
assignIntPointer(input.SowDayFrom, &species.SowDayFrom)
assignIntPointer(input.SowMonthTo, &species.SowMonthTo)
@@ -138,6 +158,12 @@ func assignIntPointer(input *int, destination **int) {
}
}
func clearIntPointer(clear bool, destination **int) {
if clear {
*destination = nil
}
}
func (app *application) createSpeciesHandler(w http.ResponseWriter, r *http.Request) {
gardenID, _ := app.readGardenIDParam(r)
var input speciesInput