mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Integrate periodic tasks
The first use case for periodic task is the cleanup of expired invitation keys. This is part of a house-keeping periodic task.
This commit is contained in:
@ -16,6 +16,9 @@ case class Timestamp(value: Instant) {
|
||||
def minus(d: Duration): Timestamp =
|
||||
Timestamp(value.minusNanos(d.nanos))
|
||||
|
||||
def - (d: Duration): Timestamp =
|
||||
minus(d)
|
||||
|
||||
def minusHours(n: Long): Timestamp =
|
||||
Timestamp(value.minusSeconds(n * 60 * 60))
|
||||
|
||||
@ -31,6 +34,9 @@ case class Timestamp(value: Instant) {
|
||||
def atUTC: ZonedDateTime = atZone(Timestamp.UTC)
|
||||
|
||||
def asString: String = value.toString
|
||||
|
||||
def < (other: Timestamp): Boolean =
|
||||
this.value.isBefore(other.value)
|
||||
}
|
||||
|
||||
object Timestamp {
|
||||
|
@ -4,6 +4,7 @@ import docspell.common._
|
||||
import _root_.pureconfig._
|
||||
import _root_.pureconfig.error.{CannotConvert, FailureReason}
|
||||
import scodec.bits.ByteVector
|
||||
import com.github.eikek.calev.CalEvent
|
||||
|
||||
import scala.reflect.ClassTag
|
||||
|
||||
@ -31,6 +32,10 @@ object Implicits {
|
||||
else ByteVector.encodeUtf8(str).left.map(ex => s"Invalid utf8 string: ${ex.getMessage}")
|
||||
})
|
||||
|
||||
implicit val caleventReader: ConfigReader[CalEvent] =
|
||||
ConfigReader[String].emap(reason(CalEvent.parse))
|
||||
|
||||
|
||||
def reason[A: ClassTag](f: String => Either[String, A]): String => Either[FailureReason, A] =
|
||||
in =>
|
||||
f(in).left.map(str => CannotConvert(in, implicitly[ClassTag[A]].runtimeClass.toString, str))
|
||||
|
Reference in New Issue
Block a user