Add granularity for aggregation, group by hour/day/month/year
This commit is contained in:
@@ -4,6 +4,7 @@ import parse.Aggregate.AggregateKey
|
||||
|
||||
import java.time.{LocalDate, LocalDateTime}
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.temporal.ChronoUnit
|
||||
import scala.util.Try
|
||||
|
||||
object ValidateRoutes {
|
||||
@@ -40,4 +41,16 @@ object ValidateRoutes {
|
||||
AggregateKey.fromString(str)
|
||||
}
|
||||
}
|
||||
|
||||
object Granularity {
|
||||
def unapply(str: String): Option[ChronoUnit] = {
|
||||
str match {
|
||||
case "hour" => Some(ChronoUnit.HOURS)
|
||||
case "day" => Some(ChronoUnit.DAYS)
|
||||
case "month" => Some(ChronoUnit.MONTHS)
|
||||
case "year" => Some(ChronoUnit.YEARS)
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user