Add granularity for aggregation, group by hour/day/month/year
This commit is contained in:
@@ -8,6 +8,7 @@ import parse.Aggregate.{AggregateKey, DoubleValue, TimeDoubleList, UserQuery}
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.temporal.ChronoUnit
|
||||
import scala.collection.immutable.HashMap
|
||||
|
||||
class ParserSpec extends AnyFunSuite with Matchers {
|
||||
@@ -16,7 +17,7 @@ class ParserSpec extends AnyFunSuite with Matchers {
|
||||
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("Bauska", "Dagda", "Daugavgrīva", "Rīga"), "precipitation", AggregateKey.Sum, ChronoUnit.HOURS)
|
||||
|
||||
val dbService = DBService.of.unsafeRunSync()
|
||||
|
||||
@@ -35,7 +36,7 @@ class ParserSpec extends AnyFunSuite with Matchers {
|
||||
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmm")
|
||||
val from = LocalDateTime.parse("20230516_0400", formatter)
|
||||
val to = LocalDateTime.parse("20230516_0800", formatter)
|
||||
val userQuery = UserQuery(List("Rīga"), "precipitation", AggregateKey.List)
|
||||
val userQuery = UserQuery(List("Rīga"), "precipitation", AggregateKey.List, ChronoUnit.HOURS)
|
||||
|
||||
val dbService = DBService.of.unsafeRunSync()
|
||||
|
||||
@@ -45,10 +46,10 @@ class ParserSpec extends AnyFunSuite with Matchers {
|
||||
parsed shouldBe HashMap(
|
||||
"Rīga" ->
|
||||
Some(TimeDoubleList(List(
|
||||
(LocalDateTime.parse("2023-05-16T04:00"), Some(1.9)),
|
||||
(LocalDateTime.parse("2023-05-16T05:00"), Some(4.5)),
|
||||
(LocalDateTime.parse("2023-05-16T06:00"), Some(1.5)),
|
||||
(LocalDateTime.parse("2023-05-16T07:00"), Some(0.0)),
|
||||
("2023-05-16T04:00", Some(1.9)),
|
||||
("2023-05-16T05:00", Some(4.5)),
|
||||
("2023-05-16T06:00", Some(1.5)),
|
||||
("2023-05-16T07:00", Some(0.0)),
|
||||
)))
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user