-
tgs266 authored
major update, includes testing, context wrapper for logger, seed data for corn, and begin process of enforcing the passing of context to downstream functions for logging purposes
tgs266 authoredmajor update, includes testing, context wrapper for logger, seed data for corn, and begin process of enforcing the passing of context to downstream functions for logging purposes
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
gdd_controller.go 1.81 KiB
package controllers
import (
"dawn-weather/context"
"dawn-weather/models"
"dawn-weather/services"
"github.com/gofiber/fiber/v2"
)
var GetGddValues = services.GetGddValues
// GetDailyGdd godoc
// @Summary Get gdd values
// @Tags Gdd
// @Description get gdd values
// @Accept json
// @Produce json
// @Success 200 {object} models.GddResponse
// @Failure 400 {object} errors.StandardError
// @Param year query int true "Year to get gdd for"
// @Param product query string true "Crop to calculate gdd for" Enums(corn, soybean, sunflower, tomato, sugar_beet, peanut, cotton, potato, wheat, pea, oat, spring_wheat, rice, sorghum)
// @Param latitude query number true "Latitude to search for"
// @Param longitude query number true "Longitude to search for"
// @Param accumulate query boolean true "Accumulate gdd values"
// @Router /api/weather/gdd/daily [get]
func GetDailyGdd(c *fiber.Ctx) error {
ctx := context.DawnCtx{FiberCtx: c}
request := models.BuildGddRequest(ctx.FiberCtx)
return c.Status(fiber.StatusOK).JSON(GetGddValues(ctx, request))
}
// GetNormalGdd godoc
// @Summary Get gdd normals
// @Tags Gdd
// @Description get gdd normals
// @Accept json
// @Produce json
// @Success 200 {object} models.GddResponse
// @Failure 400 {object} errors.StandardError
// @Param product query string true "Crop to calculate gdd for" Enums(corn, soybean, sunflower, tomato, sugar_beet, peanut, cotton, potato, wheat, pea, oat, spring_wheat, rice, sorghum)
// @Param latitude query number true "Latitude to search for"
// @Param longitude query number true "Longitude to search for"
// @Param accumulate query boolean true "Accumulate gdd values"
// @Router /api/weather/gdd/normals [get]
func GetNormalGdd(c *fiber.Ctx) error {
request := models.BuildGddRequest(c)
return c.Status(fiber.StatusOK).JSON(services.GetNormalValues(request))
}