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.feature
21 
22 import cats.data.NonEmptyList
23 import cats.implicits._
24 import grizzled.slf4j.Logging
25 import org.make.api.extensions.MakeDBExecutionContextComponent
26 import org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature
27 import org.make.api.technical.DatabaseTransactions._
28 import org.make.api.technical.PersistentServiceUtils.sortOrderQuery
29 import org.make.api.technical.{PersistentCompanion, ShortenedNames}
30 import org.make.api.technical.ScalikeSupport._
31 import org.make.core.technical.Pagination
32 import org.make.core.feature.{ActiveFeature, ActiveFeatureId, FeatureId}
33 import org.make.core.question.QuestionId
34 import org.make.core.Order
35 import scalikejdbc._
36 
37 import scala.concurrent.Future
38 
39 trait DefaultPersistentActiveFeatureServiceComponent extends PersistentActiveFeatureServiceComponent {
40   this: MakeDBExecutionContextComponent =>
41 
42   override lazy val persistentActiveFeatureService: PersistentActiveFeatureService =
43     new DefaultPersistentActiveFeatureService
44 
45   class DefaultPersistentActiveFeatureService extends PersistentActiveFeatureService with ShortenedNames with Logging {
46 
47     private val activeFeatureAlias = PersistentActiveFeature.alias
48 
49     private val column = PersistentActiveFeature.column
50 
51     override def get(activeFeatureId: ActiveFeatureId): Future[Option[ActiveFeature]] = {
52       implicit val context: EC = readExecutionContext
53       val futurePersistentActiveFeature = Future(NamedDB("READ").retryableTx { implicit session =>
54         withSQL {
55           select
56             .from(PersistentActiveFeature.as(activeFeatureAlias))
57             .where(sqls.eq(activeFeatureAlias.id, activeFeatureId))
58         }.map(PersistentActiveFeature.apply()).single()
59       })
60 
61       futurePersistentActiveFeature.map(_.map(_.toActiveFeature))
62     }
63 
64     override def persist(activeFeature: ActiveFeature): Future[ActiveFeature] = {
65       implicit val context: EC = writeExecutionContext
66       Future(NamedDB("WRITE").retryableTx { implicit session =>
67         withSQL {
68           insert
69             .into(PersistentActiveFeature)
70             .namedValues(
71               column.id -> activeFeature.activeFeatureId,
72               column.featureId -> activeFeature.featureId,
73               column.questionId -> activeFeature.maybeQuestionId
74             )
75         }.execute()
76       }).map(_ => activeFeature)
77     }
78 
79     override def remove(activeFeatureId: ActiveFeatureId): Future[Unit] = {
80       implicit val context: EC = writeExecutionContext
81       Future(NamedDB("WRITE").retryableTx { implicit session =>
82         withSQL {
83           delete
84             .from(PersistentActiveFeature.as(activeFeatureAlias))
85             .where(sqls.eq(activeFeatureAlias.id, activeFeatureId))
86         }.update()
87       }).void
88     }
89 
90     override def find(
91       offset: Pagination.Offset,
92       end: Option[Pagination.End],
93       sort: Option[String],
94       order: Option[Order],
95       maybeQuestionId: Option[Seq[QuestionId]],
96       featureId: Option[Seq[FeatureId]]
97     ): Future[Seq[ActiveFeature]] = {
98       implicit val context: EC = readExecutionContext
99 
100       val futurePersistentActiveFeatures: Future[List[PersistentActiveFeature]] = Future(NamedDB("READ").retryableTx {
101         implicit session =>
102           withSQL {
103             val query: scalikejdbc.PagingSQLBuilder[PersistentActiveFeature] =
104               select
105                 .from(PersistentActiveFeature.as(activeFeatureAlias))
106                 .where(
107                   sqls.toAndConditionOpt(
108                     maybeQuestionId.map(sqls.in(activeFeatureAlias.questionId, _)),
109                     featureId.map(sqls.in(activeFeatureAlias.featureId, _))
110                   )
111                 )
112             sortOrderQuery(offset, end, sort, order, query)
113           }.map(PersistentActiveFeature.apply()).list()
114       })
115 
116       futurePersistentActiveFeatures.map(_.map(_.toActiveFeature))
117     }
118 
119     override def count(maybeQuestionId: Option[QuestionId]): Future[Int] = {
120       implicit val context: EC = readExecutionContext
121 
122       Future(NamedDB("READ").retryableTx { implicit session =>
123         withSQL {
124           select(sqls.count)
125             .from(PersistentActiveFeature.as(activeFeatureAlias))
126             .where(
127               sqls.toAndConditionOpt(
128                 maybeQuestionId.map(questionId => sqls.eq(activeFeatureAlias.questionId, questionId))
129               )
130             )
131         }.map(_.int(1)).single().getOrElse(0)
132       })
133     }
134   }
135 }
136 
137 object DefaultPersistentActiveFeatureServiceComponent {
138 
139   final case class PersistentActiveFeature(id: String, featureId: String, questionId: Option[String]) {
140     def toActiveFeature: ActiveFeature =
141       ActiveFeature(
142         activeFeatureId = ActiveFeatureId(id),
143         featureId = FeatureId(featureId),
144         maybeQuestionId = questionId.map(QuestionId(_))
145       )
146   }
147 
148   implicit object PersistentActiveFeature
149       extends PersistentCompanion[PersistentActiveFeature, ActiveFeature]
150       with ShortenedNames
151       with Logging {
152 
153     override val columnNames: Seq[String] = Seq("id", "feature_id", "question_id")
154     final val swaggerAllowableValues = "id,feature_id,question_id"
155 
156     override val tableName: String = "active_feature"
157 
158     override lazy val alias: SyntaxProvider[PersistentActiveFeature] = syntax("active_feature")
159 
160     override lazy val defaultSortColumns: NonEmptyList[SQLSyntax] = NonEmptyList.of(alias.id)
161 
162     def apply(
163       activeFeatureResultName: ResultName[PersistentActiveFeature] = alias.resultName
164     )(resultSet: WrappedResultSet): PersistentActiveFeature = {
165       PersistentActiveFeature.apply(
166         id = resultSet.string(activeFeatureResultName.id),
167         featureId = resultSet.string(activeFeatureResultName.featureId),
168         questionId = resultSet.stringOpt(activeFeatureResultName.questionId)
169       )
170     }
171   }
172 
173 }
Line Stmt Id Pos Tree Symbol Tests Code
49 19528 1987 - 2017 Select scalikejdbc.SQLSyntaxSupportFeature.SQLSyntaxSupport.column org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.column
52 21077 2142 - 2162 Select org.make.api.extensions.MakeDBExecutionContextComponent.readExecutionContext DefaultPersistentActiveFeatureServiceComponent.this.readExecutionContext
53 20694 2205 - 2495 ApplyToImplicitArgs scala.concurrent.Future.apply scala.concurrent.Future.apply[Option[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("READ") = "READ"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("READ", x$2); scalikejdbc.NamedDB.apply("READ", x$2)(x$3) }); <artifact> val x$7: scalikejdbc.DBSession => Option[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature] @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => { <synthetic> <stable> <artifact> val stabilizer$1: scalikejdbc.SQLToOption[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = scalikejdbc.`package`.withSQL.apply[Nothing](scalikejdbc.`package`.select.from[Nothing](org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.as(DefaultPersistentActiveFeatureService.this.activeFeatureAlias)).where(scalikejdbc.`package`.sqls.eq[org.make.core.feature.ActiveFeatureId]((DefaultPersistentActiveFeatureService.this.activeFeatureAlias.field("id"): scalikejdbc.interpolation.SQLSyntax), activeFeatureId)(org.make.api.technical.ScalikeSupport.activeFeatureIdBinders))).map[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]({ <synthetic> val eta$0$1: scalikejdbc.ResultName[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature] = org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.apply$default$1; ((resultSet: scalikejdbc.WrappedResultSet) => org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.apply(eta$0$1)(resultSet)) }).single; { <artifact> val x$4: scalikejdbc.DBSession = session; <artifact> val x$5: scalikejdbc.SQL[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor] =:= scalikejdbc.SQL[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = GeneralizedTypeConstraintsForWithExtractor.this.=:=.tpEquals[scalikejdbc.SQL[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor]]; <artifact> val x$6: scalikejdbc.ConnectionPoolContext = stabilizer$1.apply$default$2(); stabilizer$1.apply()(x$4, x$6, x$5) } }); <artifact> val x$8: scalikejdbc.TxBoundary[Option[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Option[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]](x$7); qual$1.retryableTx[Option[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]](x$7)(x$8) })(context)
61 19705 2503 - 2562 ApplyToImplicitArgs scala.concurrent.Future.map futurePersistentActiveFeature.map[Option[org.make.core.feature.ActiveFeature]](((x$1: Option[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]) => x$1.map[org.make.core.feature.ActiveFeature](((x$2: org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature) => x$2.toActiveFeature))))(context)
65 21273 2685 - 2706 Select org.make.api.extensions.MakeDBExecutionContextComponent.writeExecutionContext DefaultPersistentActiveFeatureServiceComponent.this.writeExecutionContext
76 20349 2713 - 3123 ApplyToImplicitArgs scala.concurrent.Future.map scala.concurrent.Future.apply[Boolean]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("WRITE") = "WRITE"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("WRITE", x$2); scalikejdbc.NamedDB.apply("WRITE", x$2)(x$3) }); <artifact> val x$4: scalikejdbc.DBSession => Boolean @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => scalikejdbc.`package`.withSQL.apply[scalikejdbc.UpdateOperation](scalikejdbc.`package`.insert.into(org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature).namedValues((DefaultPersistentActiveFeatureService.this.column.field("id"): scalikejdbc.interpolation.SQLSyntax).->[org.make.core.feature.ActiveFeatureId](activeFeature.activeFeatureId)(org.make.api.technical.ScalikeSupport.activeFeatureIdBinders), (DefaultPersistentActiveFeatureService.this.column.field("featureId"): scalikejdbc.interpolation.SQLSyntax).->[org.make.core.feature.FeatureId](activeFeature.featureId)(org.make.api.technical.ScalikeSupport.featureIdBinders), (DefaultPersistentActiveFeatureService.this.column.field("questionId"): scalikejdbc.interpolation.SQLSyntax).->[Option[org.make.core.question.QuestionId]](activeFeature.maybeQuestionId)(scalikejdbc.this.ParameterBinderFactory.optionalParameterBinderFactory[org.make.core.question.QuestionId](org.make.api.technical.ScalikeSupport.questionIdBinders)))).execute.apply()(session)); <artifact> val x$5: scalikejdbc.TxBoundary[Boolean] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Boolean](x$4); qual$1.retryableTx[Boolean](x$4)(x$5) })(context).map[org.make.core.feature.ActiveFeature](((x$3: Boolean) => activeFeature))(context)
80 21968 3240 - 3261 Select org.make.api.extensions.MakeDBExecutionContextComponent.writeExecutionContext org.scalatest.testsuite DefaultPersistentActiveFeatureServiceComponent.this.writeExecutionContext
81 21473 3268 - 3522 ApplyToImplicitArgs scala.concurrent.Future.apply org.scalatest.testsuite scala.concurrent.Future.apply[Int]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("WRITE") = "WRITE"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("WRITE", x$2); scalikejdbc.NamedDB.apply("WRITE", x$2)(x$3) }); <artifact> val x$4: scalikejdbc.DBSession => Int @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => scalikejdbc.`package`.withSQL.apply[scalikejdbc.UpdateOperation](scalikejdbc.`package`.delete.from(org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.as(DefaultPersistentActiveFeatureService.this.activeFeatureAlias)).where(scalikejdbc.`package`.sqls.eq[org.make.core.feature.ActiveFeatureId]((DefaultPersistentActiveFeatureService.this.activeFeatureAlias.field("id"): scalikejdbc.interpolation.SQLSyntax), activeFeatureId)(org.make.api.technical.ScalikeSupport.activeFeatureIdBinders))).update.apply()(session)); <artifact> val x$5: scalikejdbc.TxBoundary[Int] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Int](x$4); qual$1.retryableTx[Int](x$4)(x$5) })(context)
81 20450 3274 - 3274 ApplyToImplicitArgs cats.instances.FutureInstances.catsStdInstancesForFuture org.scalatest.testsuite cats.implicits.catsStdInstancesForFuture(context)
87 19532 3268 - 3527 Select cats.Functor.Ops.void org.scalatest.testsuite cats.implicits.toFunctorOps[scala.concurrent.Future, Int](scala.concurrent.Future.apply[Int]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("WRITE") = "WRITE"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("WRITE", x$2); scalikejdbc.NamedDB.apply("WRITE", x$2)(x$3) }); <artifact> val x$4: scalikejdbc.DBSession => Int @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => scalikejdbc.`package`.withSQL.apply[scalikejdbc.UpdateOperation](scalikejdbc.`package`.delete.from(org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.as(DefaultPersistentActiveFeatureService.this.activeFeatureAlias)).where(scalikejdbc.`package`.sqls.eq[org.make.core.feature.ActiveFeatureId]((DefaultPersistentActiveFeatureService.this.activeFeatureAlias.field("id"): scalikejdbc.interpolation.SQLSyntax), activeFeatureId)(org.make.api.technical.ScalikeSupport.activeFeatureIdBinders))).update.apply()(session)); <artifact> val x$5: scalikejdbc.TxBoundary[Int] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Int](x$4); qual$1.retryableTx[Int](x$4)(x$5) })(context))(cats.implicits.catsStdInstancesForFuture(context)).void
98 21164 3841 - 3861 Select org.make.api.extensions.MakeDBExecutionContextComponent.readExecutionContext org.scalatest.testsuite DefaultPersistentActiveFeatureServiceComponent.this.readExecutionContext
100 20208 3945 - 4588 ApplyToImplicitArgs scala.concurrent.Future.apply org.scalatest.testsuite scala.concurrent.Future.apply[List[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("READ") = "READ"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("READ", x$2); scalikejdbc.NamedDB.apply("READ", x$2)(x$3) }); <artifact> val x$7: scalikejdbc.DBSession => List[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature] @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => { <synthetic> <stable> <artifact> val stabilizer$1: scalikejdbc.SQLToList[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = scalikejdbc.`package`.withSQL.apply[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]({ val query: scalikejdbc.PagingSQLBuilder[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature] = scalikejdbc.`package`.select.from[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature](org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.as(DefaultPersistentActiveFeatureService.this.activeFeatureAlias)).where(scalikejdbc.`package`.sqls.toAndConditionOpt(maybeQuestionId.map[scalikejdbc.interpolation.SQLSyntax](((x$4: Seq[org.make.core.question.QuestionId]) => scalikejdbc.`package`.sqls.in[org.make.core.question.QuestionId]((DefaultPersistentActiveFeatureService.this.activeFeatureAlias.field("questionId"): scalikejdbc.interpolation.SQLSyntax), x$4)(org.make.api.technical.ScalikeSupport.questionIdBinders))), featureId.map[scalikejdbc.interpolation.SQLSyntax](((x$5: Seq[org.make.core.feature.FeatureId]) => scalikejdbc.`package`.sqls.in[org.make.core.feature.FeatureId]((DefaultPersistentActiveFeatureService.this.activeFeatureAlias.field("featureId"): scalikejdbc.interpolation.SQLSyntax), x$5)(org.make.api.technical.ScalikeSupport.featureIdBinders))))); org.make.api.technical.PersistentServiceUtils.sortOrderQuery[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature, org.make.core.feature.ActiveFeature](offset, end, sort, order, query)(org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature) }).map[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]({ <synthetic> val eta$0$1: scalikejdbc.ResultName[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature] = org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.apply$default$1; ((resultSet: scalikejdbc.WrappedResultSet) => org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.apply(eta$0$1)(resultSet)) }).list; { <artifact> val x$4: scalikejdbc.DBSession = session; <artifact> val x$5: scalikejdbc.SQL[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor] =:= scalikejdbc.SQL[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = GeneralizedTypeConstraintsForWithExtractor.this.=:=.tpEquals[scalikejdbc.SQL[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature,scalikejdbc.HasExtractor]]; <artifact> val x$6: scalikejdbc.ConnectionPoolContext = stabilizer$1.apply$default$2(); stabilizer$1.apply()(x$4, x$6, x$5) } }); <artifact> val x$8: scalikejdbc.TxBoundary[List[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[List[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]](x$7); qual$1.retryableTx[List[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]](x$7)(x$8) })(context)
116 19708 4596 - 4656 ApplyToImplicitArgs scala.concurrent.Future.map org.scalatest.testsuite futurePersistentActiveFeatures.map[List[org.make.core.feature.ActiveFeature]](((x$6: List[org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature]) => x$6.map[org.make.core.feature.ActiveFeature](((x$7: org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature) => x$7.toActiveFeature))))(context)
120 21246 4774 - 4794 Select org.make.api.extensions.MakeDBExecutionContextComponent.readExecutionContext DefaultPersistentActiveFeatureServiceComponent.this.readExecutionContext
122 20352 4802 - 5216 ApplyToImplicitArgs scala.concurrent.Future.apply scala.concurrent.Future.apply[Int]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("READ") = "READ"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("READ", x$2); scalikejdbc.NamedDB.apply("READ", x$2)(x$3) }); <artifact> val x$7: scalikejdbc.DBSession => Int @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => { <synthetic> <stable> <artifact> val stabilizer$1: scalikejdbc.SQLToOption[Int,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = scalikejdbc.`package`.withSQL.apply[Nothing](scalikejdbc.`package`.select.apply[Nothing](scalikejdbc.`package`.sqls.count).from(org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.as(DefaultPersistentActiveFeatureService.this.activeFeatureAlias)).where(scalikejdbc.`package`.sqls.toAndConditionOpt(maybeQuestionId.map[scalikejdbc.interpolation.SQLSyntax](((questionId: org.make.core.question.QuestionId) => scalikejdbc.`package`.sqls.eq[org.make.core.question.QuestionId]((DefaultPersistentActiveFeatureService.this.activeFeatureAlias.field("questionId"): scalikejdbc.interpolation.SQLSyntax), questionId)(org.make.api.technical.ScalikeSupport.questionIdBinders)))))).map[Int](((x$8: scalikejdbc.WrappedResultSet) => x$8.int(1))).single; { <artifact> val x$4: scalikejdbc.DBSession = session; <artifact> val x$5: scalikejdbc.SQL[Int,scalikejdbc.HasExtractor] =:= scalikejdbc.SQL[Int,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = GeneralizedTypeConstraintsForWithExtractor.this.=:=.tpEquals[scalikejdbc.SQL[Int,scalikejdbc.HasExtractor]]; <artifact> val x$6: scalikejdbc.ConnectionPoolContext = stabilizer$1.apply$default$2(); stabilizer$1.apply()(x$4, x$6, x$5) }.getOrElse[Int](0) }); <artifact> val x$8: scalikejdbc.TxBoundary[Int] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Int](x$7); qual$1.retryableTx[Int](x$7)(x$8) })(context)
141 19685 5438 - 5605 Apply org.make.core.feature.ActiveFeature.apply org.make.core.feature.ActiveFeature.apply(org.make.core.feature.ActiveFeatureId.apply(PersistentActiveFeature.this.id), org.make.core.feature.FeatureId.apply(PersistentActiveFeature.this.featureId), PersistentActiveFeature.this.questionId.map[org.make.core.question.QuestionId](((x$9: String) => org.make.core.question.QuestionId.apply(x$9))))
142 21454 5479 - 5498 Apply org.make.core.feature.ActiveFeatureId.apply org.make.core.feature.ActiveFeatureId.apply(PersistentActiveFeature.this.id)
142 21910 5495 - 5497 Select org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.id PersistentActiveFeature.this.id
143 19492 5520 - 5540 Apply org.make.core.feature.FeatureId.apply org.make.core.feature.FeatureId.apply(PersistentActiveFeature.this.featureId)
143 20454 5530 - 5539 Select org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.featureId PersistentActiveFeature.this.featureId
144 21067 5583 - 5596 Apply org.make.core.question.QuestionId.apply org.make.core.question.QuestionId.apply(x$9)
144 20164 5568 - 5597 Apply scala.Option.map PersistentActiveFeature.this.questionId.map[org.make.core.question.QuestionId](((x$9: String) => org.make.core.question.QuestionId.apply(x$9)))
153 21248 5819 - 5857 Apply scala.collection.SeqFactory.Delegate.apply scala.`package`.Seq.apply[String]("id", "feature_id", "question_id")
154 20358 5897 - 5924 Literal <nosymbol> "id,feature_id,question_id"
156 21861 5963 - 5979 Literal <nosymbol> "active_feature"
165 21231 6344 - 6591 Apply org.make.api.feature.DefaultPersistentActiveFeatureServiceComponent.PersistentActiveFeature.apply DefaultPersistentActiveFeatureServiceComponent.this.PersistentActiveFeature.apply(resultSet.string(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("id"): scalikejdbc.interpolation.SQLSyntax))), resultSet.string(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("featureId"): scalikejdbc.interpolation.SQLSyntax))), resultSet.stringOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("questionId"): scalikejdbc.interpolation.SQLSyntax))))
166 20439 6388 - 6432 Apply scalikejdbc.WrappedResultSet.string resultSet.string(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("id"): scalikejdbc.interpolation.SQLSyntax)))
166 20947 6405 - 6431 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("id"): scalikejdbc.interpolation.SQLSyntax))
167 21075 6454 - 6505 Apply scalikejdbc.WrappedResultSet.string resultSet.string(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("featureId"): scalikejdbc.interpolation.SQLSyntax)))
167 19496 6471 - 6504 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("featureId"): scalikejdbc.interpolation.SQLSyntax))
168 20123 6548 - 6582 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("questionId"): scalikejdbc.interpolation.SQLSyntax))
168 19703 6528 - 6583 Apply scalikejdbc.WrappedResultSet.stringOpt resultSet.stringOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((activeFeatureResultName.field("questionId"): scalikejdbc.interpolation.SQLSyntax)))