Refactor main files to test files

This commit is contained in:
Guntis Smaukstelis
2023-05-25 13:06:39 +03:00
parent be037a311d
commit d651e3f3bd
7 changed files with 142 additions and 145 deletions
-3
View File
@@ -53,8 +53,6 @@ object Aggregate {
def getKeys: List[String] = {
val runtimeMirror = scala.reflect.runtime.currentMirror
val classSymbol = runtimeMirror.classSymbol(classOf[AggregateValue])
// Get all case classes that extend the AggregateValue trait
val keys = classSymbol.knownDirectSubclasses.map(_.name.toString).toList
keys
@@ -97,7 +95,6 @@ object Aggregate {
case "dewPoint" => weatherData.map(_.dewPoint)
case "humidity" => weatherData.map(_.humidity)
case "sunDuration" => weatherData.map(_.sunDuration)
// case "phenomena" => weatherData.map(_..phenomena)
case _ => List.empty
}
-35
View File
@@ -1,35 +0,0 @@
package parse
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import db.DBService
import io.circe.syntax.EncoderOps
import org.typelevel.log4cats.slf4j.Slf4jLogger
import parse.Aggregate.AggregateValueImplicits.aggregateValueEncoder
import parse.Aggregate.{AggregateKey, UserQuery}
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
object Main {
private def run: IO[Unit] = {
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmm")
val from = LocalDateTime.parse("20230515_0905", formatter)
val to = LocalDateTime.parse("20230516_0942", formatter)
val userQuery = UserQuery(List("Bauska", "Dagda", "Daugavgrīva", "Rīga"), "precipitation", AggregateKey.Sum)
// val userQuery = UserQuery(List("Daugavgrīva"), "precipitation", AggregateKey.List)
for {
log <- Slf4jLogger.create[IO]
dbService <- DBService.of
lines <- dbService.getInRange(from, to)
parsed <- IO(Parser.queryData(userQuery, lines))
_ <- log.info(parsed.asJson.toString)
} yield ()
}
def main(args: Array[String]): Unit = {
run.unsafeRunSync()
}
}