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:
Eike Kettner
2020-06-07 15:18:28 +02:00
parent 0382ff2308
commit 1d2a6e6caa
6 changed files with 117 additions and 14 deletions

View File

@ -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))