mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Get basic search summary
This commit is contained in:
@ -33,8 +33,6 @@ object QCollective {
|
||||
} yield Names(orgs.map(_.name), pers.map(_.name), equp.map(_.name)))
|
||||
.getOrElse(Names.empty)
|
||||
|
||||
case class TagCount(tag: RTag, count: Int)
|
||||
|
||||
case class InsightData(
|
||||
incoming: Int,
|
||||
outgoing: Int,
|
||||
|
@ -234,6 +234,30 @@ object QItem {
|
||||
sql.query[ListItem].stream
|
||||
}
|
||||
|
||||
def searchTagSummary(q: Query): ConnectionIO[List[TagCount]] = {
|
||||
val tagFrom =
|
||||
from(ti)
|
||||
.innerJoin(tag, tag.tid === ti.tagId)
|
||||
.innerJoin(i, i.id === ti.itemId)
|
||||
|
||||
findItemsBase(q, 0)
|
||||
.withSelect(select(tag.all).append(count(i.id).as("num")))
|
||||
.changeFrom(_.prepend(tagFrom))
|
||||
.changeWhere(c => c && queryCondition(q))
|
||||
.groupBy(tag.tid)
|
||||
.build
|
||||
.query[TagCount]
|
||||
.to[List]
|
||||
}
|
||||
|
||||
def searchCountSummary(q: Query): ConnectionIO[Int] =
|
||||
findItemsBase(q, 0)
|
||||
.withSelect(Nel.of(count(i.id).as("num")))
|
||||
.changeWhere(c => c && queryCondition(q))
|
||||
.build
|
||||
.query[Int]
|
||||
.unique
|
||||
|
||||
def findSelectedItems(
|
||||
q: Query,
|
||||
maxNoteLen: Int,
|
||||
|
@ -0,0 +1,3 @@
|
||||
package docspell.store.queries
|
||||
|
||||
case class SearchSummary(count: Int, tags: List[TagCount])
|
@ -0,0 +1,5 @@
|
||||
package docspell.store.queries
|
||||
|
||||
import docspell.store.records.RTag
|
||||
|
||||
case class TagCount(tag: RTag, count: Int)
|
Reference in New Issue
Block a user