Send no fts query if it is disabled

This commit is contained in:
eikek
2022-06-02 23:10:51 +02:00
parent 66aab0c952
commit b50f57f7fe
5 changed files with 58 additions and 43 deletions

View File

@ -147,7 +147,7 @@ object OSearch {
case Some(ftq) =>
for {
timed <- Duration.stopTime[F]
ftq <- createFtsQuery(q.fix.account, batch, ftq)
ftq <- createFtsQuery(q.fix.account, ftq)
results <- WeakAsync.liftK[F, ConnectionIO].use { nat =>
val tempTable = temporaryFtsTable(ftq, nat)
@ -206,7 +206,7 @@ object OSearch {
fulltextQuery match {
case Some(ftq) =>
for {
ftq <- createFtsQuery(q.fix.account, Batch.limit(500), ftq)
ftq <- createFtsQuery(q.fix.account, ftq)
results <- WeakAsync.liftK[F, ConnectionIO].use { nat =>
val tempTable = temporaryFtsTable(ftq, nat)
store.transact(
@ -221,13 +221,12 @@ object OSearch {
private def createFtsQuery(
account: AccountId,
batch: Batch,
ftq: String
): F[FtsQuery] =
store
.transact(QFolder.getMemberFolders(account))
.map(folders =>
FtsQuery(ftq, account.collective, batch.limit, 0)
FtsQuery(ftq, account.collective, 500, 0)
.withFolders(folders)
)

View File

@ -20,6 +20,11 @@ sealed trait QueryParseResult {
object QueryParseResult {
final case class Success(q: Query, ftq: Option[String]) extends QueryParseResult {
/** Drop the fulltext search query if disabled. */
def withFtsEnabled(enabled: Boolean) =
if (enabled || ftq.isEmpty) this else copy(ftq = None)
val get = Some(q -> ftq)
}