Get basic search summary

This commit is contained in:
Eike Kettner
2020-12-15 22:14:03 +01:00
parent 56d6d2e2ac
commit 4ca6dfccae
6 changed files with 45 additions and 4 deletions

View File

@ -66,8 +66,8 @@ trait OCollective[F[_]] {
object OCollective {
type TagCount = QCollective.TagCount
val TagCount = QCollective.TagCount
type TagCount = docspell.store.queries.TagCount
val TagCount = docspell.store.queries.TagCount
type InsightData = QCollective.InsightData
val insightData = QCollective.InsightData

View File

@ -24,6 +24,8 @@ trait OItemSearch[F[_]] {
maxNoteLen: Int
)(q: Query, batch: Batch): F[Vector[ListItemWithTags]]
def findItemsSummary(q: Query): F[SearchSummary]
def findAttachment(id: Ident, collective: Ident): F[Option[AttachmentData[F]]]
def findAttachmentSource(
@ -53,6 +55,9 @@ trait OItemSearch[F[_]] {
object OItemSearch {
type SearchSummary = queries.SearchSummary
val SearchSummary = queries.SearchSummary
type CustomValue = queries.CustomValue
val CustomValue = queries.CustomValue
@ -139,6 +144,12 @@ object OItemSearch {
.toVector
}
def findItemsSummary(q: Query): F[SearchSummary] =
for {
tags <- store.transact(QItem.searchTagSummary(q))
count <- store.transact(QItem.searchCountSummary(q))
} yield SearchSummary(count, tags)
def findAttachment(id: Ident, collective: Ident): F[Option[AttachmentData[F]]] =
store
.transact(RAttachment.findByIdAndCollective(id, collective))