Add mapping of meteo discipline, category, product
This commit is contained in:
@@ -5,8 +5,9 @@ import cats.implicits.toTraverseOps
|
||||
import com.comcast.ip4s.IpLiteralSyntax
|
||||
import db.PostgresService
|
||||
import fetch.FetchService
|
||||
import grib.GribParser
|
||||
import parse.Aggregate
|
||||
import server.ValidateRoutes.{AggFieldList, AggKey, CityList, DateTimeRange, Granularity, ValidateDate, ValidateDateTime, ValidateMonths}
|
||||
import server.ValidateRoutes.{AggFieldList, AggKey, CityList, DateTimeRange, Granularity, ValidateDate, ValidateDateTime, ValidateMonths, ValidateZonedDateTime}
|
||||
import io.circe.{Json, Printer}
|
||||
import org.http4s._
|
||||
import org.http4s.dsl.io._
|
||||
@@ -24,6 +25,7 @@ import parse.Aggregate.{AggregateKey, UserQuery}
|
||||
import org.http4s.circe.jsonEncoder
|
||||
import org.typelevel.log4cats.Logger
|
||||
import org.typelevel.log4cats.slf4j.Slf4jLogger
|
||||
import fs2.io.file.Path
|
||||
|
||||
import scala.concurrent.duration.DurationInt
|
||||
|
||||
@@ -49,6 +51,14 @@ class Server(postgresService: PostgresService, fetch: FetchService, log: Logger[
|
||||
private case class ResponseWrapper(result: Map[String, Option[Aggregate.AggregateValue]], query: UserQuery)
|
||||
|
||||
private val apiRoutes = HttpRoutes.of[IO] {
|
||||
// http://0.0.0.0:8080/api/show/grib/2025-01-24T03:00:00Z
|
||||
// case GET -> Root / "show" / "grib" / ValidateZonedDateTime(referenceTime) =>
|
||||
case GET -> Root / "show" / "grib" =>
|
||||
// TODO change from hardcoded value to reference time and forecast time
|
||||
val fileName = "data/HARMONIE_DINI_SF_2025-01-24T030000Z_2025-01-26T010000Z.grib"
|
||||
GribParser.parseFile(Path(fileName)).flatMap(response => Ok(response.asJson.pretty))
|
||||
|
||||
case GET -> Root / "show" / "gribName" => Ok("{\"fileName\":\"TODO replace this fake name\"}")
|
||||
|
||||
// http://0.0.0.0:8080/api/query/city/Liepāja,Rēzekne/20230414_2200-20230501_1230/hour/tempMax/max
|
||||
case GET -> Root / "query" / "city" / CityList(cities) / DateTimeRange(from, to) / Granularity(granularity) / field / AggKey(key) =>
|
||||
|
||||
Reference in New Issue
Block a user