Add backend operations for re-creating the full-text index

This commit is contained in:
Eike Kettner
2020-06-21 15:46:51 +02:00
parent 14ea4091c4
commit 0d8b03fc61
13 changed files with 237 additions and 58 deletions

View File

@ -147,7 +147,10 @@ object QAttachment {
name: Option[String],
content: Option[String]
)
def allAttachmentMetaAndName(chunkSize: Int): Stream[ConnectionIO, ContentAndName] = {
def allAttachmentMetaAndName(
coll: Option[Ident],
chunkSize: Int
): Stream[ConnectionIO, ContentAndName] = {
val aId = RAttachment.Columns.id.prefix("a")
val aItem = RAttachment.Columns.itemId.prefix("a")
val aName = RAttachment.Columns.name.prefix("a")
@ -164,7 +167,9 @@ object QAttachment {
fr"INNER JOIN" ++ RItem.table ++ fr"i ON" ++ iId.is(aItem) ++
fr"INNER JOIN" ++ RCollective.table ++ fr"c ON" ++ cId.is(iColl)
selectSimple(cols, from, Fragment.empty)
val where = coll.map(cid => iColl.is(cid)).getOrElse(Fragment.empty)
selectSimple(cols, from, where)
.query[ContentAndName]
.streamWithChunkSize(chunkSize)
}

View File

@ -475,14 +475,18 @@ object QItem {
name: String,
notes: Option[String]
)
def allNameAndNotes(chunkSize: Int): Stream[ConnectionIO, NameAndNotes] = {
def allNameAndNotes(
coll: Option[Ident],
chunkSize: Int
): Stream[ConnectionIO, NameAndNotes] = {
val iId = RItem.Columns.id
val iColl = RItem.Columns.cid
val iName = RItem.Columns.name
val iNotes = RItem.Columns.notes
val cols = Seq(iId, iColl, iName, iNotes)
selectSimple(cols, RItem.table, Fragment.empty)
val cols = Seq(iId, iColl, iName, iNotes)
val where = coll.map(cid => iColl.is(cid)).getOrElse(Fragment.empty)
selectSimple(cols, RItem.table, where)
.query[NameAndNotes]
.streamWithChunkSize(chunkSize)
}