Skip to content

Commit

Permalink
[TRELLO-2737] Fix search by subcategories (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlescd authored Jan 8, 2025
1 parent 286bfff commit 21187e6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions app/repositories/report/ReportRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,6 @@ object ReportRepository {
}
}

// Utilisé pour caster un type mal généré par slick : @>
// Cette fonction attend le même type à gauche et à droite
// mais slick génère varchar[] @> text[]
private val castVarCharArrayToTextArray = SimpleExpression.unary[List[String], List[String]] { (s, qb) =>
qb.sqlBuilder += "CAST( ": Unit
qb.expr(s)
qb.sqlBuilder += " AS TEXT[])": Unit
}

def queryFilter(
table: Query[ReportTable, Report, Seq],
filter: ReportFilter,
Expand Down Expand Up @@ -697,9 +688,6 @@ object ReportRepository {
table.category === category
}
}
.filterIf(filter.subcategories.nonEmpty) { table =>
castVarCharArrayToTextArray(table.subcategories) @> filter.subcategories.toList.bind
}
.filterIf(filter.status.nonEmpty)(table => table.status.inSetBind(filter.status.map(_.entryName)))
.filterIf(filter.withTags.nonEmpty) { table =>
table.tags @& filter.withTags.toList.bind
Expand Down Expand Up @@ -813,6 +801,10 @@ object ReportRepository {
val bookmarkExists = bookmark.isDefined
if (isBookmarked) bookmarkExists else !bookmarkExists
}
.filterIf(filter.subcategories.nonEmpty) { case (_, _, _, subcategoryLabelTable) =>
subcategoryLabelTable.flatMap(_.subcategoryLabelsFr) @> filter.subcategories.toList.bind ||
subcategoryLabelTable.flatMap(_.subcategoryLabelsEn) @> filter.subcategories.toList.bind
}
}

}

0 comments on commit 21187e6

Please sign in to comment.