mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Remove unused code (search update)
This commit is contained in:
@ -73,14 +73,6 @@ object QItem extends FtsSupport {
|
||||
sql.query[ListItem].stream
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
def countAttachmentsAndItems(items: Nel[Ident]): ConnectionIO[Int] =
|
||||
Select(count(a.id).s, from(a), a.itemId.in(items)).build
|
||||
.query[Int]
|
||||
.unique
|
||||
.map(_ + items.size)
|
||||
|
||||
def findItem(id: Ident, collective: Ident): ConnectionIO[Option[ItemData]] = {
|
||||
val ref = RItem.as("ref")
|
||||
val cq =
|
||||
@ -314,14 +306,6 @@ object QItem extends FtsSupport {
|
||||
Condition.unit
|
||||
}
|
||||
|
||||
def findItems(
|
||||
q: Query,
|
||||
today: LocalDate,
|
||||
maxNoteLen: Int,
|
||||
batch: Batch
|
||||
): Stream[ConnectionIO, ListItem] =
|
||||
queryItems(q, today, maxNoteLen, batch, None)
|
||||
|
||||
def searchStats(today: LocalDate, ftsTable: Option[RFtsResult.Table])(
|
||||
q: Query
|
||||
): ConnectionIO[SearchSummary] =
|
||||
@ -524,47 +508,6 @@ object QItem extends FtsSupport {
|
||||
}
|
||||
}
|
||||
|
||||
def findSelectedItems(
|
||||
q: Query,
|
||||
today: LocalDate,
|
||||
maxNoteLen: Int,
|
||||
items: Set[SelectedItem]
|
||||
): Stream[ConnectionIO, ListItem] =
|
||||
if (items.isEmpty) Stream.empty
|
||||
else {
|
||||
val i = RItem.as("i")
|
||||
|
||||
object Tids extends TableDef {
|
||||
val tableName = "tids"
|
||||
val alias = Some("tw")
|
||||
val itemId = Column[Ident]("item_id", this)
|
||||
val weight = Column[Double]("weight", this)
|
||||
val all = Vector[Column[_]](itemId, weight)
|
||||
}
|
||||
|
||||
val cte =
|
||||
CteBind(
|
||||
Tids,
|
||||
Tids.all,
|
||||
Select.RawSelect(
|
||||
fr"VALUES" ++
|
||||
items
|
||||
.map(it => fr"(${it.itemId}, ${it.weight})")
|
||||
.reduce((r, e) => r ++ fr"," ++ e)
|
||||
)
|
||||
)
|
||||
|
||||
val from = findItemsBase(q.fix, today, maxNoteLen, None)
|
||||
.appendCte(cte)
|
||||
.appendSelect(Tids.weight.s)
|
||||
.changeFrom(_.innerJoin(Tids, Tids.itemId === i.id))
|
||||
.orderBy(Tids.weight.desc)
|
||||
.build
|
||||
|
||||
logger.stream.trace(s"fts query: $from").drain ++
|
||||
from.query[ListItem].stream
|
||||
}
|
||||
|
||||
/** Same as `findItems` but resolves the tags for each item. Note that this is
|
||||
* implemented by running an additional query per item.
|
||||
*/
|
||||
|
@ -17,6 +17,15 @@ case class Query(fix: Query.Fix, cond: Query.QueryCond) {
|
||||
def withCond(f: Query.QueryCond => Query.QueryCond): Query =
|
||||
copy(cond = f(cond))
|
||||
|
||||
def andCond(c: ItemQuery.Expr): Query =
|
||||
withCond {
|
||||
case Query.QueryExpr(Some(q)) =>
|
||||
Query.QueryExpr(ItemQuery.Expr.and(q, c))
|
||||
|
||||
case Query.QueryExpr(None) =>
|
||||
Query.QueryExpr(c)
|
||||
}
|
||||
|
||||
def withOrder(orderAsc: RItem.Table => Column[_]): Query =
|
||||
withFix(_.copy(order = Some(_.byItemColumnAsc(orderAsc))))
|
||||
|
||||
|
Reference in New Issue
Block a user