1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 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.question
21 
22 import akka.stream.scaladsl.{Sink, Source}
23 import cats.data.NonEmptyList
24 import cats.implicits._
25 import eu.timepit.refined.api.Refined
26 import eu.timepit.refined.collection._
27 import org.make.api.organisation.OrganisationSearchEngineComponent
28 import org.make.api.personality.QuestionPersonalityServiceComponent
29 import org.make.api.proposal.ProposalSearchEngineComponent
30 import org.make.api.technical.{ActorSystemComponent, IdGeneratorComponent}
31 import org.make.api.user.UserServiceComponent
32 import org.make.core.technical.{Multilingual, Pagination}
33 import org.make.core.operation.OperationId
34 import org.make.core.personality.PersonalityRoleId
35 import org.make.core.question.{Question, QuestionId}
36 import org.make.core.reference.{Country, Language}
37 import org.make.core.user._
38 import org.make.core.user.indexed.OrganisationSearchResult
39 import org.make.core.{ValidationError, ValidationFailedError}
40 import scalacache._
41 import scalacache.guava._
42 import scalacache.modes.scalaFuture._
43 
44 import scala.concurrent.ExecutionContext.Implicits.global
45 import scala.concurrent.Future
46 import scala.concurrent.duration.DurationInt
47 import org.make.core.technical.Pagination._
48 import scalacache.memoization.memoizeF
49 
50 trait DefaultQuestionServiceComponent extends QuestionServiceComponent {
51   this: PersistentQuestionServiceComponent
52     with ActorSystemComponent
53     with IdGeneratorComponent
54     with QuestionPersonalityServiceComponent
55     with UserServiceComponent
56     with OrganisationSearchEngineComponent
57     with ProposalSearchEngineComponent =>
58 
59   override lazy val questionService: QuestionService = new DefaultQuestionService
60 
61   class DefaultQuestionService extends QuestionService {
62 
63     implicit val guavaCache: Cache[Option[Question]] = GuavaCache[Option[Question]]
64 
65     override def getQuestions(questionIds: Seq[QuestionId]): Future[Seq[Question]] = {
66       persistentQuestionService.getByIds(questionIds)
67     }
68 
69     override def getQuestionByQuestionIdValueOrSlug(questionIdValueOrSlug: String): Future[Option[Question]] = {
70       persistentQuestionService.getByQuestionIdValueOrSlug(questionIdValueOrSlug)
71     }
72 
73     override def getQuestion(questionId: QuestionId): Future[Option[Question]] = {
74       persistentQuestionService.getById(questionId)
75     }
76 
77     override def getCachedQuestion(questionId: QuestionId): Future[Option[Question]] = {
78       memoizeF[Future, Option[Question]](Some(3.hours)) {
79         getQuestion(questionId)
80       }
81     }
82 
83     override def findQuestion(
84       maybeOperationId: Option[OperationId],
85       country: Country,
86       language: Language
87     ): Future[Option[Question]] = {
88 
89       maybeOperationId match {
90         case None =>
91           Future.failed(
92             ValidationFailedError(
93               Seq(ValidationError("unknown", "mandatory", Some("operationId must be provided to question search")))
94             )
95           )
96         case _ =>
97           persistentQuestionService
98             .find(
99               SearchQuestionRequest(
100                 country = Some(country),
101                 language = Some(language),
102                 maybeOperationIds = maybeOperationId.map(operationId => Seq(operationId))
103               )
104             )
105             .map(_.headOption)
106       }
107 
108     }
109 
110     override def searchQuestion(request: SearchQuestionRequest): Future[Seq[Question]] = {
111       persistentQuestionService.find(request)
112     }
113 
114     override def countQuestion(request: SearchQuestionRequest): Future[Int] = {
115       persistentQuestionService.count(request)
116     }
117 
118     override def createQuestion(
119       countries: NonEmptyList[Country],
120       defaultLanguage: Language,
121       languages: NonEmptyList[Language],
122       questions: Multilingual[String Refined NonEmpty],
123       shortTitles: Option[Multilingual[String Refined NonEmpty]],
124       slug: String
125     ): Future[Question] = {
126       persistentQuestionService.persist(
127         Question(
128           questionId = idGenerator.nextQuestionId(),
129           slug = slug,
130           countries = countries,
131           defaultLanguage = defaultLanguage,
132           languages = languages,
133           questions = questions,
134           shortTitles = shortTitles,
135           operationId = None
136         )
137       )
138     }
139 
140     override def getQuestionPersonalities(
141       offset: Offset,
142       end: Option[End],
143       questionId: QuestionId,
144       personalityRoleId: Option[PersonalityRoleId]
145     ): Future[Seq[QuestionPersonalityResponse]] = {
146       Source
147         .future(
148           questionPersonalityService.find(
149             offset = offset,
150             end = end,
151             sort = None,
152             order = None,
153             userId = None,
154             questionId = Some(questionId),
155             personalityRoleId = personalityRoleId
156           )
157         )
158         .mapConcat(identity)
159         .mapAsync(1) { personality =>
160           userService.getPersonality(personality.userId)
161         }
162         .collect {
163           case Some(user) =>
164             QuestionPersonalityResponse(
165               userId = user.userId,
166               firstName = user.firstName,
167               lastName = user.lastName,
168               politicalParty = user.profile.flatMap(_.politicalParty),
169               avatarUrl = user.profile.flatMap(_.avatarUrl),
170               gender = user.profile.flatMap(_.gender.map(_.value))
171             )
172         }
173         .runWith(Sink.seq[QuestionPersonalityResponse])
174     }
175 
176     override def getPartners(
177       questionId: QuestionId,
178       organisationIds: Seq[UserId],
179       sortAlgorithm: Option[OrganisationSortAlgorithm],
180       limit: Option[Pagination.Limit],
181       offset: Option[Pagination.Offset]
182     ): Future[OrganisationSearchResult] = {
183       val query = OrganisationSearchQuery(
184         filters = Some(OrganisationSearchFilters(organisationIds = Some(OrganisationIdsSearchFilter(organisationIds)))),
185         sortAlgorithm = sortAlgorithm,
186         limit = sortAlgorithm.as(Pagination.Limit(1000)).orElse(limit),
187         offset = sortAlgorithm.as(Pagination.Offset(0)).orElse(offset)
188       )
189 
190       val offsetOrZero = offset.fold(0)(_.extractInt)
191       elasticsearchOrganisationAPI.searchOrganisations(query).map { organisationSearchResult =>
192         sortAlgorithm.collect {
193           case ParticipationAlgorithm(_) =>
194             organisationSearchResult.copy(results = organisationSearchResult.results.sortBy { orga =>
195               orga.countsByQuestion.collect {
196                 case counts if counts.questionId == questionId =>
197                   counts.proposalsCount + counts.votesCount
198               }.sum * -1
199             }.slice(offsetOrZero, offsetOrZero + limit.fold(organisationSearchResult.total.toInt)(_.extractInt)))
200         }.getOrElse(organisationSearchResult)
201       }
202 
203     }
204   }
205 }
Line Stmt Id Pos Tree Symbol Tests Code
63 27182 2516 - 2516 Select scalacache.CacheConfig.defaultCacheConfig org.make.api.question.questionservicetest scalacache.this.CacheConfig.defaultCacheConfig
63 24924 2506 - 2534 ApplyToImplicitArgs scalacache.guava.GuavaCache.apply org.make.api.question.questionservicetest scalacache.guava.GuavaCache.apply[Option[org.make.core.question.Question]](scalacache.this.CacheConfig.defaultCacheConfig)
66 22752 2629 - 2676 Apply org.make.api.question.PersistentQuestionService.getByIds DefaultQuestionServiceComponent.this.persistentQuestionService.getByIds(questionIds)
70 26423 2803 - 2878 Apply org.make.api.question.PersistentQuestionService.getByQuestionIdValueOrSlug DefaultQuestionServiceComponent.this.persistentQuestionService.getByQuestionIdValueOrSlug(questionIdValueOrSlug)
74 24159 2975 - 3020 Apply org.make.api.question.PersistentQuestionService.getById DefaultQuestionServiceComponent.this.persistentQuestionService.getById(questionId)
91 22977 3446 - 3637 Apply scala.concurrent.Future.failed scala.concurrent.Future.failed[Nothing](org.make.core.ValidationFailedError.apply(scala.`package`.Seq.apply[org.make.core.ValidationError](org.make.core.ValidationError.apply("unknown", "mandatory", scala.Some.apply[String]("operationId must be provided to question search")))))
92 24935 3473 - 3625 Apply org.make.core.ValidationFailedError.apply org.make.core.ValidationFailedError.apply(scala.`package`.Seq.apply[org.make.core.ValidationError](org.make.core.ValidationError.apply("unknown", "mandatory", scala.Some.apply[String]("operationId must be provided to question search"))))
93 26272 3510 - 3611 Apply scala.collection.SeqFactory.Delegate.apply scala.`package`.Seq.apply[org.make.core.ValidationError](org.make.core.ValidationError.apply("unknown", "mandatory", scala.Some.apply[String]("operationId must be provided to question search")))
93 22281 3514 - 3610 Apply org.make.core.ValidationError.apply org.make.core.ValidationError.apply("unknown", "mandatory", scala.Some.apply[String]("operationId must be provided to question search"))
93 26806 3541 - 3552 Literal <nosymbol> "mandatory"
93 23049 3530 - 3539 Literal <nosymbol> "unknown"
93 24843 3554 - 3609 Apply scala.Some.apply scala.Some.apply[String]("operationId must be provided to question search")
99 24310 3725 - 3937 Apply org.make.api.question.SearchQuestionRequest.apply SearchQuestionRequest.apply(x$4, x$3, x$1, x$2, x$5, x$6, x$7, x$8, x$9)
99 25165 3725 - 3725 Select org.make.api.question.SearchQuestionRequest.apply$default$7 SearchQuestionRequest.apply$default$7
99 26734 3725 - 3725 Select org.make.api.question.SearchQuestionRequest.apply$default$9 SearchQuestionRequest.apply$default$9
99 24853 3725 - 3725 Select org.make.api.question.SearchQuestionRequest.apply$default$1 SearchQuestionRequest.apply$default$1
99 26282 3725 - 3725 Select org.make.api.question.SearchQuestionRequest.apply$default$6 SearchQuestionRequest.apply$default$6
99 22911 3725 - 3725 Select org.make.api.question.SearchQuestionRequest.apply$default$8 SearchQuestionRequest.apply$default$8
99 22591 3725 - 3725 Select org.make.api.question.SearchQuestionRequest.apply$default$5 SearchQuestionRequest.apply$default$5
100 26723 3774 - 3787 Apply scala.Some.apply scala.Some.apply[org.make.core.reference.Country](country)
101 24386 3816 - 3830 Apply scala.Some.apply scala.Some.apply[org.make.core.reference.Language](language)
102 23185 3904 - 3920 Apply scala.collection.SeqFactory.Delegate.apply scala.`package`.Seq.apply[org.make.core.operation.OperationId](operationId)
102 26817 3868 - 3921 Apply scala.Option.map maybeOperationId.map[Seq[org.make.core.operation.OperationId]](((operationId: org.make.core.operation.OperationId) => scala.`package`.Seq.apply[org.make.core.operation.OperationId](operationId)))
105 23197 3969 - 3981 Select scala.collection.IterableOps.headOption x$1.headOption
105 24787 3666 - 3982 ApplyToImplicitArgs scala.concurrent.Future.map DefaultQuestionServiceComponent.this.persistentQuestionService.find({ <artifact> val x$1: Some[org.make.core.reference.Country] @scala.reflect.internal.annotations.uncheckedBounds = scala.Some.apply[org.make.core.reference.Country](country); <artifact> val x$2: Some[org.make.core.reference.Language] @scala.reflect.internal.annotations.uncheckedBounds = scala.Some.apply[org.make.core.reference.Language](language); <artifact> val x$3: Option[Seq[org.make.core.operation.OperationId]] @scala.reflect.internal.annotations.uncheckedBounds = maybeOperationId.map[Seq[org.make.core.operation.OperationId]](((operationId: org.make.core.operation.OperationId) => scala.`package`.Seq.apply[org.make.core.operation.OperationId](operationId))); <artifact> val x$4: Option[Seq[org.make.core.question.QuestionId]] @scala.reflect.internal.annotations.uncheckedBounds = SearchQuestionRequest.apply$default$1; <artifact> val x$5: Option[String] @scala.reflect.internal.annotations.uncheckedBounds = SearchQuestionRequest.apply$default$5; <artifact> val x$6: Option[org.make.core.technical.Pagination.Offset] @scala.reflect.internal.annotations.uncheckedBounds = SearchQuestionRequest.apply$default$6; <artifact> val x$7: Option[org.make.core.technical.Pagination.End] @scala.reflect.internal.annotations.uncheckedBounds = SearchQuestionRequest.apply$default$7; <artifact> val x$8: Option[String] @scala.reflect.internal.annotations.uncheckedBounds = SearchQuestionRequest.apply$default$8; <artifact> val x$9: Option[org.make.core.Order] @scala.reflect.internal.annotations.uncheckedBounds = SearchQuestionRequest.apply$default$9; SearchQuestionRequest.apply(x$4, x$3, x$1, x$2, x$5, x$6, x$7, x$8, x$9) }).map[Option[org.make.core.question.Question]](((x$1: Seq[org.make.core.question.Question]) => x$1.headOption))(scala.concurrent.ExecutionContext.Implicits.global)
105 26877 3968 - 3968 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
111 22436 4096 - 4135 Apply org.make.api.question.PersistentQuestionService.find DefaultQuestionServiceComponent.this.persistentQuestionService.find(request)
115 26206 4229 - 4269 Apply org.make.api.question.PersistentQuestionService.count DefaultQuestionServiceComponent.this.persistentQuestionService.count(request)
126 24319 4599 - 4955 Apply org.make.api.question.PersistentQuestionService.persist DefaultQuestionServiceComponent.this.persistentQuestionService.persist(org.make.core.question.Question.apply(DefaultQuestionServiceComponent.this.idGenerator.nextQuestionId(), slug, countries, defaultLanguage, languages, questions, shortTitles, scala.None))
127 26665 4642 - 4947 Apply org.make.core.question.Question.apply org.make.core.question.Question.apply(DefaultQuestionServiceComponent.this.idGenerator.nextQuestionId(), slug, countries, defaultLanguage, languages, questions, shortTitles, scala.None)
128 25086 4675 - 4703 Apply org.make.core.technical.IdGenerator.nextQuestionId DefaultQuestionServiceComponent.this.idGenerator.nextQuestionId()
135 22746 4933 - 4937 Select scala.None scala.None
148 26219 5225 - 5492 Apply org.make.api.personality.QuestionPersonalityService.find org.make.api.question.questionservicetest DefaultQuestionServiceComponent.this.questionPersonalityService.find(offset, end, scala.None, scala.None, scala.None, scala.Some.apply[org.make.core.question.QuestionId](questionId), personalityRoleId)
151 28156 5329 - 5333 Select scala.None org.make.api.question.questionservicetest scala.None
152 26802 5355 - 5359 Select scala.None org.make.api.question.questionservicetest scala.None
153 24629 5382 - 5386 Select scala.None org.make.api.question.questionservicetest scala.None
154 22367 5413 - 5429 Apply scala.Some.apply org.make.api.question.questionservicetest scala.Some.apply[org.make.core.question.QuestionId](questionId)
158 24930 5522 - 5530 Apply scala.Predef.identity scala.Predef.identity[Seq[org.make.core.personality.Personality]](x)
159 22675 5550 - 5551 Literal <nosymbol> org.make.api.question.questionservicetest 1
160 24329 5580 - 5626 Apply org.make.api.user.UserService.getPersonality DefaultQuestionServiceComponent.this.userService.getPersonality(personality.userId)
160 26718 5607 - 5625 Select org.make.core.personality.Personality.userId personality.userId
162 24780 5654 - 5654 Apply org.make.api.question.DefaultQuestionServiceComponent.DefaultQuestionService.$anonfun.<init> org.make.api.question.questionservicetest new $anonfun()
164 27115 5697 - 6056 Apply org.make.api.question.QuestionPersonalityResponse.apply QuestionPersonalityResponse.apply(user.userId, user.firstName, user.lastName, user.profile.flatMap[String](((x$2: org.make.core.profile.Profile) => x$2.politicalParty)), user.profile.flatMap[String](((x$3: org.make.core.profile.Profile) => x$3.avatarUrl)), user.profile.flatMap[String](((x$4: org.make.core.profile.Profile) => x$4.gender.map[String](((x$5: org.make.core.profile.Gender) => x$5.value)))))
165 28085 5749 - 5760 Select org.make.core.user.User.userId user.userId
166 26811 5788 - 5802 Select org.make.core.user.User.firstName user.firstName
167 24559 5829 - 5842 Select org.make.core.user.User.lastName user.lastName
168 26232 5875 - 5913 Apply scala.Option.flatMap user.profile.flatMap[String](((x$2: org.make.core.profile.Profile) => x$2.politicalParty))
168 22585 5896 - 5912 Select org.make.core.profile.Profile.politicalParty x$2.politicalParty
169 23807 5962 - 5973 Select org.make.core.profile.Profile.avatarUrl x$3.avatarUrl
169 22687 5941 - 5974 Apply scala.Option.flatMap user.profile.flatMap[String](((x$3: org.make.core.profile.Profile) => x$3.avatarUrl))
170 26654 6033 - 6040 Select org.make.core.profile.Gender.value x$5.value
170 27931 5999 - 6042 Apply scala.Option.flatMap user.profile.flatMap[String](((x$4: org.make.core.profile.Profile) => x$4.gender.map[String](((x$5: org.make.core.profile.Gender) => x$5.value))))
170 24475 6020 - 6041 Apply scala.Option.map x$4.gender.map[String](((x$5: org.make.core.profile.Gender) => x$5.value))
173 26362 6083 - 6083 Select org.make.api.technical.ActorSystemComponent.actorSystem org.make.api.question.questionservicetest DefaultQuestionServiceComponent.this.actorSystem
173 23821 6083 - 6083 ApplyToImplicitArgs akka.stream.Materializer.matFromSystem org.make.api.question.questionservicetest stream.this.Materializer.matFromSystem(DefaultQuestionServiceComponent.this.actorSystem)
173 22989 5191 - 6122 ApplyToImplicitArgs akka.stream.scaladsl.Source.runWith org.make.api.question.questionservicetest akka.stream.scaladsl.Source.future[Seq[org.make.core.personality.Personality]](DefaultQuestionServiceComponent.this.questionPersonalityService.find(offset, end, scala.None, scala.None, scala.None, scala.Some.apply[org.make.core.question.QuestionId](questionId), personalityRoleId)).mapConcat[org.make.core.personality.Personality](((x: Seq[org.make.core.personality.Personality]) => scala.Predef.identity[Seq[org.make.core.personality.Personality]](x))).mapAsync[Option[org.make.core.user.User]](1)(((personality: org.make.core.personality.Personality) => DefaultQuestionServiceComponent.this.userService.getPersonality(personality.userId))).collect[org.make.api.question.QuestionPersonalityResponse](({ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[Option[org.make.core.user.User],org.make.api.question.QuestionPersonalityResponse] with java.io.Serializable { def <init>(): <$anon: Option[org.make.core.user.User] => org.make.api.question.QuestionPersonalityResponse> = { $anonfun.super.<init>(); () }; final override def applyOrElse[A1 <: Option[org.make.core.user.User], B1 >: org.make.api.question.QuestionPersonalityResponse](x1: A1, default: A1 => B1): B1 = ((x1.asInstanceOf[Option[org.make.core.user.User]]: Option[org.make.core.user.User]): Option[org.make.core.user.User] @unchecked) match { case (value: org.make.core.user.User): Some[org.make.core.user.User]((user @ _)) => QuestionPersonalityResponse.apply(user.userId, user.firstName, user.lastName, user.profile.flatMap[String](((x$2: org.make.core.profile.Profile) => x$2.politicalParty)), user.profile.flatMap[String](((x$3: org.make.core.profile.Profile) => x$3.avatarUrl)), user.profile.flatMap[String](((x$4: org.make.core.profile.Profile) => x$4.gender.map[String](((x$5: org.make.core.profile.Gender) => x$5.value))))) case (defaultCase$ @ _) => default.apply(x1) }; final def isDefinedAt(x1: Option[org.make.core.user.User]): Boolean = ((x1.asInstanceOf[Option[org.make.core.user.User]]: Option[org.make.core.user.User]): Option[org.make.core.user.User] @unchecked) match { case (value: org.make.core.user.User): Some[org.make.core.user.User]((user @ _)) => true case (defaultCase$ @ _) => false } }; new $anonfun() }: PartialFunction[Option[org.make.core.user.User],org.make.api.question.QuestionPersonalityResponse])).runWith[scala.concurrent.Future[Seq[org.make.api.question.QuestionPersonalityResponse]]](akka.stream.scaladsl.Sink.seq[org.make.api.question.QuestionPersonalityResponse])(stream.this.Materializer.matFromSystem(DefaultQuestionServiceComponent.this.actorSystem))
173 22597 6084 - 6121 TypeApply akka.stream.scaladsl.Sink.seq org.make.api.question.questionservicetest akka.stream.scaladsl.Sink.seq[org.make.api.question.QuestionPersonalityResponse]
183 28081 6423 - 6423 Select org.make.core.user.OrganisationSearchQuery.apply$default$4 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchQuery.apply$default$4
183 25848 6423 - 6423 Select org.make.core.user.OrganisationSearchQuery.apply$default$5 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchQuery.apply$default$5
183 24726 6423 - 6758 Apply org.make.core.user.OrganisationSearchQuery.apply org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchQuery.apply(x$1, x$3, x$4, x$5, x$6, x$2)
184 27124 6471 - 6471 Select org.make.core.user.OrganisationSearchFilters.apply$default$3 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchFilters.apply$default$3
184 23966 6471 - 6566 Apply org.make.core.user.OrganisationSearchFilters.apply org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchFilters.apply(scala.Some.apply[org.make.core.user.OrganisationIdsSearchFilter](org.make.core.user.OrganisationIdsSearchFilter.apply(organisationIds)), org.make.core.user.OrganisationSearchFilters.apply$default$2, org.make.core.user.OrganisationSearchFilters.apply$default$3, org.make.core.user.OrganisationSearchFilters.apply$default$4, org.make.core.user.OrganisationSearchFilters.apply$default$5, org.make.core.user.OrganisationSearchFilters.apply$default$6)
184 24719 6471 - 6471 Select org.make.core.user.OrganisationSearchFilters.apply$default$4 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchFilters.apply$default$4
184 22999 6466 - 6567 Apply scala.Some.apply org.make.api.question.questionservicetest scala.Some.apply[org.make.core.user.OrganisationSearchFilters](org.make.core.user.OrganisationSearchFilters.apply(scala.Some.apply[org.make.core.user.OrganisationIdsSearchFilter](org.make.core.user.OrganisationIdsSearchFilter.apply(organisationIds)), org.make.core.user.OrganisationSearchFilters.apply$default$2, org.make.core.user.OrganisationSearchFilters.apply$default$3, org.make.core.user.OrganisationSearchFilters.apply$default$4, org.make.core.user.OrganisationSearchFilters.apply$default$5, org.make.core.user.OrganisationSearchFilters.apply$default$6))
184 28071 6471 - 6471 Select org.make.core.user.OrganisationSearchFilters.apply$default$2 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchFilters.apply$default$2
184 26213 6471 - 6471 Select org.make.core.user.OrganisationSearchFilters.apply$default$6 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchFilters.apply$default$6
184 26662 6520 - 6564 Apply org.make.core.user.OrganisationIdsSearchFilter.apply org.make.api.question.questionservicetest org.make.core.user.OrganisationIdsSearchFilter.apply(organisationIds)
184 22526 6471 - 6471 Select org.make.core.user.OrganisationSearchFilters.apply$default$5 org.make.api.question.questionservicetest org.make.core.user.OrganisationSearchFilters.apply$default$5
184 24484 6515 - 6565 Apply scala.Some.apply org.make.api.question.questionservicetest scala.Some.apply[org.make.core.user.OrganisationIdsSearchFilter](org.make.core.user.OrganisationIdsSearchFilter.apply(organisationIds))
186 26668 6624 - 6678 Apply scala.Option.orElse org.make.api.question.questionservicetest cats.implicits.toFunctorOps[Option, org.make.core.user.OrganisationSortAlgorithm](sortAlgorithm)(cats.implicits.catsStdInstancesForOption).as[org.make.core.technical.Pagination.Limit](org.make.core.technical.Pagination.Limit.apply(1000)).orElse[org.make.core.technical.Pagination.Limit](limit)
187 24409 6697 - 6750 Apply scala.Option.orElse org.make.api.question.questionservicetest cats.implicits.toFunctorOps[Option, org.make.core.user.OrganisationSortAlgorithm](sortAlgorithm)(cats.implicits.catsStdInstancesForOption).as[org.make.core.technical.Pagination.Offset](org.make.core.technical.Pagination.Offset.apply(0)).orElse[org.make.core.technical.Pagination.Offset](offset)
190 26146 6800 - 6812 Select org.make.core.technical.Pagination.extractInt x$6.extractInt
190 22533 6797 - 6798 Literal <nosymbol> org.make.api.question.questionservicetest 0
190 23976 6785 - 6813 Apply scala.Option.fold org.make.api.question.questionservicetest offset.fold[Int](0)(((x$6: org.make.core.technical.Pagination.Offset) => x$6.extractInt))
191 26600 6880 - 6880 Select scala.concurrent.ExecutionContext.Implicits.global org.make.api.question.questionservicetest scala.concurrent.ExecutionContext.Implicits.global
191 24263 6820 - 7452 ApplyToImplicitArgs scala.concurrent.Future.map org.make.api.question.questionservicetest DefaultQuestionServiceComponent.this.elasticsearchOrganisationAPI.searchOrganisations(query).map[org.make.core.user.indexed.OrganisationSearchResult](((organisationSearchResult: org.make.core.user.indexed.OrganisationSearchResult) => sortAlgorithm.collect[org.make.core.user.indexed.OrganisationSearchResult](({ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[org.make.core.user.OrganisationSortAlgorithm,org.make.core.user.indexed.OrganisationSearchResult] with java.io.Serializable { def <init>(): <$anon: org.make.core.user.OrganisationSortAlgorithm => org.make.core.user.indexed.OrganisationSearchResult> = { $anonfun.super.<init>(); () }; final override def applyOrElse[A1 <: org.make.core.user.OrganisationSortAlgorithm, B1 >: org.make.core.user.indexed.OrganisationSearchResult](x1: A1, default: A1 => B1): B1 = ((x1.asInstanceOf[org.make.core.user.OrganisationSortAlgorithm]: org.make.core.user.OrganisationSortAlgorithm): org.make.core.user.OrganisationSortAlgorithm @unchecked) match { case (questionId: org.make.core.question.QuestionId): org.make.core.user.ParticipationAlgorithm(_) => { <artifact> val x$1: Seq[org.make.core.user.indexed.IndexedOrganisation] @scala.reflect.internal.annotations.uncheckedBounds = organisationSearchResult.results.sortBy[Int](((orga: org.make.core.user.indexed.IndexedOrganisation) => orga.countsByQuestion.collect[Int](({ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion,Int] with java.io.Serializable { def <init>(): <$anon: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion => Int> = { $anonfun.super.<init>(); () }; final override def applyOrElse[A1 <: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion, B1 >: Int](x1: A1, default: A1 => B1): B1 = ((x1.asInstanceOf[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion]: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion): org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion @unchecked) match { case (counts @ _) if counts.questionId.==(questionId) => counts.proposalsCount.+(counts.votesCount) case (defaultCase$ @ _) => default.apply(x1) }; final def isDefinedAt(x1: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion): Boolean = ((x1.asInstanceOf[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion]: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion): org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion @unchecked) match { case (counts @ _) if counts.questionId.==(questionId) => true case (defaultCase$ @ _) => false } }; new $anonfun() }: PartialFunction[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion,Int])).sum[Int](math.this.Numeric.IntIsIntegral).*(-1)))(cats.implicits.catsKernelOrderingForOrder[Int](cats.implicits.catsKernelStdOrderForInt)).slice(offsetOrZero, offsetOrZero.+(limit.fold[Int](organisationSearchResult.total.toInt)(((x$7: org.make.core.technical.Pagination.Limit) => x$7.extractInt)))); <artifact> val x$2: Long = organisationSearchResult.copy$default$1; organisationSearchResult.copy(x$2, x$1) } case (defaultCase$ @ _) => default.apply(x1) }; final def isDefinedAt(x1: org.make.core.user.OrganisationSortAlgorithm): Boolean = ((x1.asInstanceOf[org.make.core.user.OrganisationSortAlgorithm]: org.make.core.user.OrganisationSortAlgorithm): org.make.core.user.OrganisationSortAlgorithm @unchecked) match { case (questionId: org.make.core.question.QuestionId): org.make.core.user.ParticipationAlgorithm(_) => true case (defaultCase$ @ _) => false } }; new $anonfun() }: PartialFunction[org.make.core.user.OrganisationSortAlgorithm,org.make.core.user.indexed.OrganisationSearchResult])).getOrElse[org.make.core.user.indexed.OrganisationSearchResult](organisationSearchResult)))(scala.concurrent.ExecutionContext.Implicits.global)
200 22683 6918 - 7444 Apply scala.Option.getOrElse sortAlgorithm.collect[org.make.core.user.indexed.OrganisationSearchResult](({ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[org.make.core.user.OrganisationSortAlgorithm,org.make.core.user.indexed.OrganisationSearchResult] with java.io.Serializable { def <init>(): <$anon: org.make.core.user.OrganisationSortAlgorithm => org.make.core.user.indexed.OrganisationSearchResult> = { $anonfun.super.<init>(); () }; final override def applyOrElse[A1 <: org.make.core.user.OrganisationSortAlgorithm, B1 >: org.make.core.user.indexed.OrganisationSearchResult](x1: A1, default: A1 => B1): B1 = ((x1.asInstanceOf[org.make.core.user.OrganisationSortAlgorithm]: org.make.core.user.OrganisationSortAlgorithm): org.make.core.user.OrganisationSortAlgorithm @unchecked) match { case (questionId: org.make.core.question.QuestionId): org.make.core.user.ParticipationAlgorithm(_) => { <artifact> val x$1: Seq[org.make.core.user.indexed.IndexedOrganisation] @scala.reflect.internal.annotations.uncheckedBounds = organisationSearchResult.results.sortBy[Int](((orga: org.make.core.user.indexed.IndexedOrganisation) => orga.countsByQuestion.collect[Int](({ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion,Int] with java.io.Serializable { def <init>(): <$anon: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion => Int> = { $anonfun.super.<init>(); () }; final override def applyOrElse[A1 <: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion, B1 >: Int](x1: A1, default: A1 => B1): B1 = ((x1.asInstanceOf[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion]: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion): org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion @unchecked) match { case (counts @ _) if counts.questionId.==(questionId) => counts.proposalsCount.+(counts.votesCount) case (defaultCase$ @ _) => default.apply(x1) }; final def isDefinedAt(x1: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion): Boolean = ((x1.asInstanceOf[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion]: org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion): org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion @unchecked) match { case (counts @ _) if counts.questionId.==(questionId) => true case (defaultCase$ @ _) => false } }; new $anonfun() }: PartialFunction[org.make.core.user.indexed.ProposalsAndVotesCountsByQuestion,Int])).sum[Int](math.this.Numeric.IntIsIntegral).*(-1)))(cats.implicits.catsKernelOrderingForOrder[Int](cats.implicits.catsKernelStdOrderForInt)).slice(offsetOrZero, offsetOrZero.+(limit.fold[Int](organisationSearchResult.total.toInt)(((x$7: org.make.core.technical.Pagination.Limit) => x$7.extractInt)))); <artifact> val x$2: Long = organisationSearchResult.copy$default$1; organisationSearchResult.copy(x$2, x$1) } case (defaultCase$ @ _) => default.apply(x1) }; final def isDefinedAt(x1: org.make.core.user.OrganisationSortAlgorithm): Boolean = ((x1.asInstanceOf[org.make.core.user.OrganisationSortAlgorithm]: org.make.core.user.OrganisationSortAlgorithm): org.make.core.user.OrganisationSortAlgorithm @unchecked) match { case (questionId: org.make.core.question.QuestionId): org.make.core.user.ParticipationAlgorithm(_) => true case (defaultCase$ @ _) => false } }; new $anonfun() }: PartialFunction[org.make.core.user.OrganisationSortAlgorithm,org.make.core.user.indexed.OrganisationSearchResult])).getOrElse[org.make.core.user.indexed.OrganisationSearchResult](organisationSearchResult)