mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Allow to use the created timestamp in item queries
Refs: 925
This commit is contained in:
@ -53,6 +53,7 @@ object ItemQuery {
|
||||
case object ItemId extends StringAttr
|
||||
case object Date extends DateAttr
|
||||
case object DueDate extends DateAttr
|
||||
case object CreatedDate extends DateAttr
|
||||
case object AttachCount extends IntAttr
|
||||
|
||||
object Correspondent {
|
||||
|
@ -31,6 +31,9 @@ object AttrParser {
|
||||
val dueDate: P[Attr.DateAttr] =
|
||||
P.ignoreCase(C.due).as(Attr.DueDate)
|
||||
|
||||
val created: P[Attr.DateAttr] =
|
||||
P.ignoreCase(C.created).as(Attr.CreatedDate)
|
||||
|
||||
val corrOrgId: P[Attr.StringAttr] =
|
||||
P.ignoreCase(C.corrOrgId)
|
||||
.as(Attr.Correspondent.OrgId)
|
||||
@ -78,7 +81,7 @@ object AttrParser {
|
||||
attachCountAttr
|
||||
|
||||
val dateAttr: P[Attr.DateAttr] =
|
||||
P.oneOf(List(date, dueDate))
|
||||
P.oneOf(List(date, dueDate, created))
|
||||
|
||||
val stringAttr: P[Attr.StringAttr] =
|
||||
P.oneOf(
|
||||
|
@ -23,6 +23,8 @@ object Constants {
|
||||
val corrOrgName = "corr.org.name"
|
||||
val corrPersId = "corr.pers.id"
|
||||
val corrPersName = "corr.pers.name"
|
||||
val created = "created"
|
||||
val createdIn = "createdIn"
|
||||
val customField = "f"
|
||||
val customFieldId = "f.id"
|
||||
val date = "date"
|
||||
|
@ -35,6 +35,9 @@ object MacroParser {
|
||||
val dueDateRangeMacro: P[Expr.DateRangeMacro] =
|
||||
dateRangeMacroImpl(C.dueIn, Attr.DueDate)
|
||||
|
||||
val createdDateRangeMacro: P[Expr.DateRangeMacro] =
|
||||
dateRangeMacroImpl(C.createdIn, Attr.CreatedDate)
|
||||
|
||||
val yearDateMacro: P[Expr.YearMacro] =
|
||||
yearMacroImpl(C.year, Attr.Date)
|
||||
|
||||
@ -52,6 +55,7 @@ object MacroParser {
|
||||
namesMacro,
|
||||
dateRangeMacro,
|
||||
dueDateRangeMacro,
|
||||
createdDateRangeMacro,
|
||||
yearDateMacro,
|
||||
corrMacro,
|
||||
concMacro
|
||||
|
@ -56,6 +56,14 @@ class SimpleExprParserTest extends FunSuite with ValueHelper {
|
||||
p.parseAll("due<2021-03-14"),
|
||||
Right(dateExpr(Operator.Lt, Attr.DueDate, ld(2021, 3, 14)))
|
||||
)
|
||||
assertEquals(
|
||||
p.parseAll("created:2021-03-14"),
|
||||
Right(dateExpr(Operator.Like, Attr.CreatedDate, ld(2021, 3, 14)))
|
||||
)
|
||||
assertEquals(
|
||||
p.parseAll("created<2021-03-14"),
|
||||
Right(dateExpr(Operator.Lt, Attr.CreatedDate, ld(2021, 3, 14)))
|
||||
)
|
||||
assertEquals(
|
||||
p.parseAll("due~=2021-03-14,2021-03-13"),
|
||||
Right(Expr.InDateExpr(Attr.DueDate, Nel.of(ld(2021, 3, 14), ld(2021, 3, 13))))
|
||||
|
Reference in New Issue
Block a user