1 /* 2 * Make.org Core API 3 * Copyright (C) 2021 Make.org 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Affero General Public License for more details. 14 * 15 * You should have received a copy of the GNU Affero General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package org.make.api.idea 21 22 import com.sksamuel.elastic4s.requests.searches.suggestion.Fuzziness 23 import org.make.core.{Order, RequestContext} 24 import org.make.core.technical.Pagination 25 import org.make.core.idea.{IdeaSearchFilters, IdeaSearchQuery, NameSearchFilter, QuestionIdSearchFilter} 26 import org.make.core.question.QuestionId 27 28 final case class IdeaFiltersRequest( 29 name: Option[String], 30 questionId: Option[QuestionId], 31 limit: Option[Pagination.Limit], 32 offset: Option[Pagination.Offset], 33 sort: Option[String], 34 order: Option[Order] 35 ) { 36 37 private lazy val filters: Option[IdeaSearchFilters] = { 38 val nameFilter = name.map(NameSearchFilter(_, Some(Fuzziness.Auto))) 39 val questionIdFilter = questionId.map(QuestionIdSearchFilter.apply) 40 IdeaSearchFilters.parse(nameFilter, questionIdFilter) 41 } 42 43 def toSearchQuery(requestContext: RequestContext): IdeaSearchQuery = { 44 IdeaSearchQuery( 45 filters = filters, 46 limit = limit, 47 offset = offset, 48 sort = sort, 49 order = order, 50 language = requestContext.languageContext.language 51 ) 52 } 53 } 54 55 object IdeaFiltersRequest { 56 val empty: IdeaFiltersRequest = IdeaFiltersRequest(None, None, None, None, None, None) 57 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 44 | 30476 | 1637 - 1825 | Apply | org.make.core.idea.IdeaSearchQuery.apply | org.scalatest.testsuite | org.make.core.idea.IdeaSearchQuery.apply(IdeaFiltersRequest.this.filters, IdeaFiltersRequest.this.limit, IdeaFiltersRequest.this.offset, IdeaFiltersRequest.this.sort, IdeaFiltersRequest.this.order, requestContext.languageContext.language) |
| 46 | 30467 | 1693 - 1698 | Select | org.make.api.idea.IdeaFiltersRequest.limit | org.scalatest.testsuite | IdeaFiltersRequest.this.limit |
| 47 | 30459 | 1715 - 1721 | Select | org.make.api.idea.IdeaFiltersRequest.offset | org.scalatest.testsuite | IdeaFiltersRequest.this.offset |
| 48 | 30473 | 1736 - 1740 | Select | org.make.api.idea.IdeaFiltersRequest.sort | org.scalatest.testsuite | IdeaFiltersRequest.this.sort |
| 49 | 30462 | 1756 - 1761 | Select | org.make.api.idea.IdeaFiltersRequest.order | org.scalatest.testsuite | IdeaFiltersRequest.this.order |
| 50 | 30460 | 1780 - 1819 | Select | org.make.core.RequestContextLanguage.language | org.scalatest.testsuite | requestContext.languageContext.language |
| 56 | 30471 | 1926 - 1930 | Select | scala.None | org.scalatest.testsuite | scala.None |
| 56 | 30456 | 1920 - 1924 | Select | scala.None | org.scalatest.testsuite | scala.None |
| 56 | 30463 | 1895 - 1949 | Apply | org.make.api.idea.IdeaFiltersRequest.apply | org.scalatest.testsuite | IdeaFiltersRequest.apply(scala.None, scala.None, scala.None, scala.None, scala.None, scala.None) |
| 56 | 30457 | 1938 - 1942 | Select | scala.None | org.scalatest.testsuite | scala.None |
| 56 | 30466 | 1914 - 1918 | Select | scala.None | org.scalatest.testsuite | scala.None |
| 56 | 30474 | 1944 - 1948 | Select | scala.None | org.scalatest.testsuite | scala.None |
| 56 | 30468 | 1932 - 1936 | Select | scala.None | org.scalatest.testsuite | scala.None |