Implement notify-due-items task

This commit is contained in:
Eike Kettner
2020-04-21 21:43:05 +02:00
parent e7b81c701f
commit 2723d6b43b
11 changed files with 215 additions and 10 deletions

View File

@ -43,6 +43,9 @@ object Duration {
def hours(n: Long): Duration =
apply(JDur.ofHours(n))
def days(n: Long): Duration =
apply(JDur.ofDays(n))
def nanos(n: Long): Duration =
Duration(n)

View File

@ -24,6 +24,9 @@ object ItemState {
case _ => Left(s"Invalid item state: $str")
}
val validStates: Seq[ItemState] =
Seq(Created, Confirmed)
def unsafe(str: String): ItemState =
fromString(str).fold(sys.error, identity)

View File

@ -19,6 +19,12 @@ case class Timestamp(value: Instant) {
def -(d: Duration): Timestamp =
minus(d)
def +(d: Duration): Timestamp =
plus(d)
def plus(d: Duration): Timestamp =
Timestamp(value.plusNanos(d.nanos))
def minusHours(n: Long): Timestamp =
Timestamp(value.minusSeconds(n * 60 * 60))
@ -59,4 +65,6 @@ object Timestamp {
implicit val decodeTimestamp: Decoder[Timestamp] =
BaseJsonCodecs.decodeInstantEpoch.map(Timestamp(_))
implicit val ordering: Ordering[Timestamp] =
Ordering.by(_.value)
}