mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-31 05:15:08 +00:00
Sort due items by their earliest due date
This commit is contained in:
parent
e1f9ae2629
commit
ffc1cdee51
@ -26,7 +26,7 @@ this is Docspell informing you about due items coming up.
|
||||
{{/more}}
|
||||
|
||||
|
||||
Sincerly,
|
||||
Sincerely yours,
|
||||
Docspell
|
||||
"""
|
||||
|
||||
|
@ -73,7 +73,8 @@ object NotifyDueItemsTask {
|
||||
states = ItemState.validStates,
|
||||
tagsInclude = ctx.args.tagsInclude,
|
||||
tagsExclude = ctx.args.tagsExclude,
|
||||
dueDateTo = Some(now + Duration.days(ctx.args.remindDays.toLong))
|
||||
dueDateTo = Some(now + Duration.days(ctx.args.remindDays.toLong)),
|
||||
orderAsc = Some(_.dueDate)
|
||||
)
|
||||
res <- ctx.store.transact(QItem.findItems(q).take(maxItems)).compile.toVector
|
||||
} yield res
|
||||
|
@ -120,7 +120,8 @@ trait Conversions {
|
||||
m.dateFrom,
|
||||
m.dateUntil,
|
||||
m.dueDateFrom,
|
||||
m.dueDateUntil
|
||||
m.dueDateUntil,
|
||||
None
|
||||
)
|
||||
|
||||
def mkItemList(v: Vector[OItem.ListItem]): ItemLightList = {
|
||||
|
@ -9,6 +9,7 @@ import doobie.implicits._
|
||||
import docspell.common.{IdRef, _}
|
||||
import docspell.store.Store
|
||||
import docspell.store.records._
|
||||
import docspell.store.impl._
|
||||
import docspell.store.impl.Implicits._
|
||||
import org.log4s._
|
||||
|
||||
@ -122,7 +123,8 @@ object QItem {
|
||||
dateFrom: Option[Timestamp],
|
||||
dateTo: Option[Timestamp],
|
||||
dueDateFrom: Option[Timestamp],
|
||||
dueDateTo: Option[Timestamp]
|
||||
dueDateTo: Option[Timestamp],
|
||||
orderAsc: Option[RItem.Columns.type => Column]
|
||||
)
|
||||
|
||||
object Query {
|
||||
@ -141,6 +143,7 @@ object QItem {
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None
|
||||
)
|
||||
}
|
||||
@ -173,7 +176,13 @@ object QItem {
|
||||
PC.pid.prefix("p1").f,
|
||||
PC.name.prefix("p1").f,
|
||||
EC.eid.prefix("e1").f,
|
||||
EC.name.prefix("e1").f
|
||||
EC.name.prefix("e1").f,
|
||||
q.orderAsc match {
|
||||
case Some(co) =>
|
||||
coalesce(co(IC).prefix("i").f, IC.created.prefix("i").f)
|
||||
case None =>
|
||||
IC.created.prefix("i").f
|
||||
}
|
||||
)
|
||||
|
||||
val withItem = selectSimple(itemCols, RItem.table, IC.cid.is(q.collective))
|
||||
@ -258,9 +267,14 @@ object QItem {
|
||||
q.dueDateTo.map(d => IC.dueDate.prefix("i").isLt(d)).getOrElse(Fragment.empty)
|
||||
)
|
||||
|
||||
val order = orderBy(
|
||||
coalesce(IC.itemDate.prefix("i").f, IC.created.prefix("i").f) ++ fr"DESC"
|
||||
)
|
||||
val order = q.orderAsc match {
|
||||
case Some(co) =>
|
||||
orderBy(coalesce(co(IC).prefix("i").f, IC.created.prefix("i").f) ++ fr"ASC")
|
||||
case None =>
|
||||
orderBy(
|
||||
coalesce(IC.itemDate.prefix("i").f, IC.created.prefix("i").f) ++ fr"DESC"
|
||||
)
|
||||
}
|
||||
val frag = query ++ fr"WHERE" ++ cond ++ order
|
||||
logger.trace(s"List items: $frag")
|
||||
frag.query[ListItem].stream
|
||||
|
Loading…
x
Reference in New Issue
Block a user