mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Add endpoint to search for items and return their tags
This is a more expensive query, since the tags must be resolved per item. This is now implemented by doing additional queries while caching each resolved tag.
This commit is contained in:
@ -15,6 +15,7 @@ import OItem.{
|
||||
Batch,
|
||||
ItemData,
|
||||
ListItem,
|
||||
ListItemWithTags,
|
||||
Query
|
||||
}
|
||||
import bitpeace.{FileMeta, RangeDef}
|
||||
@ -27,6 +28,9 @@ trait OItem[F[_]] {
|
||||
|
||||
def findItems(q: Query, batch: Batch): F[Vector[ListItem]]
|
||||
|
||||
/** Same as `findItems` but does more queries per item to find all tags. */
|
||||
def findItemsWithTags(q: Query, batch: Batch): F[Vector[ListItemWithTags]]
|
||||
|
||||
def findAttachment(id: Ident, collective: Ident): F[Option[AttachmentData[F]]]
|
||||
|
||||
def findAttachmentSource(
|
||||
@ -91,6 +95,9 @@ object OItem {
|
||||
type ListItem = QItem.ListItem
|
||||
val ListItem = QItem.ListItem
|
||||
|
||||
type ListItemWithTags = QItem.ListItemWithTags
|
||||
val ListItemWithTags = QItem.ListItemWithTags
|
||||
|
||||
type ItemData = QItem.ItemData
|
||||
val ItemData = QItem.ItemData
|
||||
|
||||
@ -148,6 +155,12 @@ object OItem {
|
||||
.compile
|
||||
.toVector
|
||||
|
||||
def findItemsWithTags(q: Query, batch: Batch): F[Vector[ListItemWithTags]] =
|
||||
store
|
||||
.transact(QItem.findItemsWithTags(q, batch).take(batch.limit.toLong))
|
||||
.compile
|
||||
.toVector
|
||||
|
||||
def findAttachment(id: Ident, collective: Ident): F[Option[AttachmentData[F]]] =
|
||||
store
|
||||
.transact(RAttachment.findByIdAndCollective(id, collective))
|
||||
|
Reference in New Issue
Block a user