1 /* 2 * Make.org Core API 3 * Copyright (C) 2020 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.technical.graphql 21 22 import org.make.api.organisation.OrganisationServiceComponent 23 import org.make.core.user.UserId 24 import zio.query.DataSource 25 26 import scala.concurrent.{ExecutionContext, Future} 27 28 trait GraphQLOrganisationServiceComponent { 29 def organisationDataSource: DataSource[Any, GetOrganisations] 30 } 31 32 trait DefaultGraphQLOrganisationServiceComponent extends GraphQLOrganisationServiceComponent { 33 this: OrganisationServiceComponent => 34 35 override val organisationDataSource: DataSource[Any, GetOrganisations] = { 36 def findFromIds(organisationsIds: Seq[UserId])(ec: ExecutionContext): Future[Map[UserId, GraphQLOrganisation]] = 37 organisationService 38 .search(None, None, Some(organisationsIds), None, None) 39 .map( 40 _.results 41 .map( 42 orga => orga.organisationId -> GraphQLOrganisation(orga.organisationId, orga.organisationName, orga.slug) 43 ) 44 .toMap 45 )(ec) 46 47 DataSourceHelper.seq("organisation-datasource", findFromIds) 48 } 49 50 } 51 52 final case class GetOrganisations(ids: List[UserId]) extends IdsRequest[List, UserId, GraphQLOrganisation] 53 final case class GraphQLOrganisation( 54 organisationId: UserId, 55 organisationName: Option[String], 56 organisationSlug: Option[String] 57 )
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 45 | 33588 | 1408 - 1710 | Apply | scala.concurrent.Future.map | DefaultGraphQLOrganisationServiceComponent.this.organisationService.search(scala.None, scala.None, scala.Some.apply[Seq[org.make.core.user.UserId]](organisationsIds), scala.None, scala.None).map[scala.collection.immutable.Map[org.make.core.user.UserId,org.make.api.technical.graphql.GraphQLOrganisation]](((x$1: org.make.core.user.indexed.OrganisationSearchResult) => x$1.results.map[(org.make.core.user.UserId, org.make.api.technical.graphql.GraphQLOrganisation)](((orga: org.make.core.user.indexed.IndexedOrganisation) => scala.Predef.ArrowAssoc[org.make.core.user.UserId](orga.organisationId).->[org.make.api.technical.graphql.GraphQLOrganisation](GraphQLOrganisation.apply(orga.organisationId, orga.organisationName, orga.slug)))).toMap[org.make.core.user.UserId, org.make.api.technical.graphql.GraphQLOrganisation](scala.this.<:<.refl[(org.make.core.user.UserId, org.make.api.technical.graphql.GraphQLOrganisation)])))(ec) | |
| 47 | 31657 | 1716 - 1776 | Apply | org.make.api.technical.graphql.DataSourceHelper.seq | DataSourceHelper.seq[org.make.core.user.UserId, org.make.api.technical.graphql.GraphQLOrganisation, org.make.api.technical.graphql.GetOrganisations]("organisation-datasource", ((organisationsIds: Seq[org.make.core.user.UserId]) => ((ec: scala.concurrent.ExecutionContext) => findFromIds(organisationsIds)(ec)))) | |
| 47 | 46349 | 1737 - 1762 | Literal | <nosymbol> | "organisation-datasource" | |
| 47 | 38480 | 1764 - 1775 | Apply | org.make.api.technical.graphql.DefaultGraphQLOrganisationServiceComponent.findFromIds | findFromIds(organisationsIds)(ec) |