mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Fix obvious things and add search summary
This commit is contained in:
@ -23,7 +23,7 @@ trait FtsSupport {
|
||||
val tt = cteTable(ftst)
|
||||
select
|
||||
.appendCte(ftst.distinctCteSimple(tt.tableName))
|
||||
.changeFrom(_.innerJoin(tt, itemTable.id === tt.id))
|
||||
.changeFrom(_.prepend(from(itemTable).innerJoin(tt, itemTable.id === tt.id)))
|
||||
case None =>
|
||||
select
|
||||
}
|
||||
@ -37,7 +37,19 @@ trait FtsSupport {
|
||||
val tt = cteTable(ftst)
|
||||
select
|
||||
.appendCte(ftst.distinctCte(tt.tableName))
|
||||
.changeFrom(_.innerJoin(tt, itemTable.id === tt.id))
|
||||
.changeFrom(_.prepend(from(itemTable).innerJoin(tt, itemTable.id === tt.id)))
|
||||
case None =>
|
||||
select
|
||||
}
|
||||
|
||||
def ftsCondition(
|
||||
itemTable: RItem.Table,
|
||||
ftsTable: Option[TempFtsTable.Table]
|
||||
): Select =
|
||||
ftsTable match {
|
||||
case Some(ftst) =>
|
||||
val ftsIds = Select(ftst.id.s, from(ftst)).distinct
|
||||
select.changeWhere(c => c && itemTable.id.in(ftsIds))
|
||||
case None =>
|
||||
select
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ case class ListItem(
|
||||
|
||||
def decodeContext: Option[Either[String, List[ContextEntry]]] =
|
||||
context.map(_.trim).filter(_.nonEmpty).map { str =>
|
||||
// This is a bit… well. The common denominator for the dbms used is string aggregation
|
||||
// This is a bit…. The common denominator for the dbms used is string aggregation
|
||||
// when combining multiple matches. So the `ContextEntry` objects are concatenated and
|
||||
// separated by comma. TemplateFtsTable ensures than the single entries are all json
|
||||
// objects.
|
||||
@ -40,4 +40,7 @@ case class ListItem(
|
||||
.map(_.getMessage)
|
||||
.map(_.flatten)
|
||||
}
|
||||
|
||||
def toWithTags: ListItemWithTags =
|
||||
ListItemWithTags(this, Nil, Nil, Nil, Nil)
|
||||
}
|
||||
|
@ -475,9 +475,9 @@ object QItem extends FtsSupport {
|
||||
|
||||
val base =
|
||||
findItemsBase(q.fix, today, 0, None).unwrap
|
||||
.joinFtsIdOnly(i, ftsTable)
|
||||
.changeFrom(_.prepend(fieldJoin))
|
||||
.changeWhere(c => c && queryCondition(today, q.fix.account.collective, q.cond))
|
||||
.ftsCondition(i, ftsTable)
|
||||
.groupBy(GroupBy(cf.all))
|
||||
|
||||
val basicFields = Nel.of(
|
||||
|
Reference in New Issue
Block a user