mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Add more convenient date parsers and some basic macros
This commit is contained in:
@ -159,13 +159,14 @@ object OFulltext {
|
||||
|
||||
for {
|
||||
folder <- store.transact(QFolder.getMemberFolders(account))
|
||||
now <- Timestamp.current[F]
|
||||
itemIds <- fts
|
||||
.searchAll(fq.withFolders(folder))
|
||||
.flatMap(r => Stream.emits(r.results.map(_.itemId)))
|
||||
.compile
|
||||
.to(Set)
|
||||
q = Query.empty(account).withFix(_.copy(itemIds = itemIds.some))
|
||||
res <- store.transact(QItem.searchStats(q))
|
||||
res <- store.transact(QItem.searchStats(now.toUtcDate)(q))
|
||||
} yield res
|
||||
}
|
||||
|
||||
@ -221,7 +222,8 @@ object OFulltext {
|
||||
.compile
|
||||
.to(Set)
|
||||
qnext = q.withFix(_.copy(itemIds = items.some))
|
||||
res <- store.transact(QItem.searchStats(qnext))
|
||||
now <- Timestamp.current[F]
|
||||
res <- store.transact(QItem.searchStats(now.toUtcDate)(qnext))
|
||||
} yield res
|
||||
|
||||
// Helper
|
||||
|
@ -127,27 +127,39 @@ object OItemSearch {
|
||||
.map(opt => opt.flatMap(_.filterCollective(collective)))
|
||||
|
||||
def findItems(maxNoteLen: Int)(q: Query, batch: Batch): F[Vector[ListItem]] =
|
||||
store
|
||||
.transact(QItem.findItems(q, maxNoteLen, batch).take(batch.limit.toLong))
|
||||
.compile
|
||||
.toVector
|
||||
Timestamp
|
||||
.current[F]
|
||||
.map(_.toUtcDate)
|
||||
.flatMap { today =>
|
||||
store
|
||||
.transact(
|
||||
QItem.findItems(q, today, maxNoteLen, batch).take(batch.limit.toLong)
|
||||
)
|
||||
.compile
|
||||
.toVector
|
||||
}
|
||||
|
||||
def findItemsWithTags(
|
||||
maxNoteLen: Int
|
||||
)(q: Query, batch: Batch): F[Vector[ListItemWithTags]] = {
|
||||
val search = QItem.findItems(q, maxNoteLen: Int, batch)
|
||||
store
|
||||
.transact(
|
||||
QItem
|
||||
.findItemsWithTags(q.fix.account.collective, search)
|
||||
.take(batch.limit.toLong)
|
||||
)
|
||||
.compile
|
||||
.toVector
|
||||
}
|
||||
)(q: Query, batch: Batch): F[Vector[ListItemWithTags]] =
|
||||
for {
|
||||
now <- Timestamp.current[F]
|
||||
search = QItem.findItems(q, now.toUtcDate, maxNoteLen: Int, batch)
|
||||
res <- store
|
||||
.transact(
|
||||
QItem
|
||||
.findItemsWithTags(q.fix.account.collective, search)
|
||||
.take(batch.limit.toLong)
|
||||
)
|
||||
.compile
|
||||
.toVector
|
||||
} yield res
|
||||
|
||||
def findItemsSummary(q: Query): F[SearchSummary] =
|
||||
store.transact(QItem.searchStats(q))
|
||||
Timestamp
|
||||
.current[F]
|
||||
.map(_.toUtcDate)
|
||||
.flatMap(today => store.transact(QItem.searchStats(today)(q)))
|
||||
|
||||
def findAttachment(id: Ident, collective: Ident): F[Option[AttachmentData[F]]] =
|
||||
store
|
||||
|
Reference in New Issue
Block a user