diff --git a/common/src/main/scala/no/ndla/common/model/domain/learningpath/LearningPath.scala b/common/src/main/scala/no/ndla/common/model/domain/learningpath/LearningPath.scala index 736647ab3..f18d02330 100644 --- a/common/src/main/scala/no/ndla/common/model/domain/learningpath/LearningPath.scala +++ b/common/src/main/scala/no/ndla/common/model/domain/learningpath/LearningPath.scala @@ -45,7 +45,7 @@ case class LearningPath( ) ++ stepLanguages).distinct } - def isPrivate: Boolean = status == LearningPathStatus.PRIVATE + def isPrivate: Boolean = Seq(LearningPathStatus.PRIVATE, LearningPathStatus.READY_FOR_SHARING).contains(status) def isPublished: Boolean = status == LearningPathStatus.PUBLISHED def isDeleted: Boolean = status == LearningPathStatus.DELETED diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/LearningpathControllerV2.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/LearningpathControllerV2.scala index 8b70f6ad7..c47c713e9 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/LearningpathControllerV2.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/LearningpathControllerV2.scala @@ -37,13 +37,13 @@ import scala.util.{Failure, Success, Try} trait LearningpathControllerV2 { - this: ReadService & - UpdateService with SearchService with LanguageValidator with ConverterService with TaxonomyApiClient with SearchConverterServiceComponent with Props with ErrorHandling with TapirController => + this: ReadService & UpdateService & SearchService & LanguageValidator & ConverterService & TaxonomyApiClient & + SearchConverterServiceComponent & Props & ErrorHandling & TapirController => val learningpathControllerV2: LearningpathControllerV2 class LearningpathControllerV2 extends TapirController { - import ErrorHelpers._ + import ErrorHelpers.* import props.{ DefaultLanguage, ElasticSearchIndexMaxResultWindow, diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/StatsController.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/StatsController.scala index 26c067521..b92e11c7a 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/StatsController.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/StatsController.scala @@ -17,7 +17,7 @@ import sttp.tapir.* import sttp.tapir.server.ServerEndpoint trait StatsController { - this: ReadService with Props with ErrorHandling with TapirController => + this: ReadService & Props & ErrorHandling & TapirController => val statsController: StatsController class StatsController extends TapirController { diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/SwaggerDocControllerConfig.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/SwaggerDocControllerConfig.scala index 07f2577d8..a01bcba7f 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/SwaggerDocControllerConfig.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/controller/SwaggerDocControllerConfig.scala @@ -10,7 +10,7 @@ package no.ndla.learningpathapi.controller import no.ndla.learningpathapi.Props import no.ndla.network.tapir.auth.Permission import no.ndla.network.tapir.{SwaggerControllerConfig, SwaggerInfo} -import sttp.tapir._ +import sttp.tapir.* trait SwaggerDocControllerConfig { this: Props & SwaggerControllerConfig => diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/OembedProxyClient.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/OembedProxyClient.scala index af2551a39..5bce726fe 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/OembedProxyClient.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/OembedProxyClient.scala @@ -26,7 +26,7 @@ object OembedResponse { } trait OembedProxyClient { - this: NdlaClient with Props => + this: NdlaClient & Props => val oembedProxyClient: OembedProxyClient class OembedProxyClient extends StrictLogging { @@ -48,7 +48,7 @@ trait OembedProxyClient { } private def getOembed(url: String): Try[OembedResponse] = { - get[OembedResponse](s"$OembedProxyBaseUrl/oembed", ("url" -> url)) + get[OembedResponse](s"$OembedProxyBaseUrl/oembed", "url" -> url) } private def get[A: Decoder](url: String, params: (String, String)*): Try[A] = { diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/SearchApiClient.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/SearchApiClient.scala index 6e5a69b0a..60d7c932f 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/SearchApiClient.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/SearchApiClient.scala @@ -20,7 +20,7 @@ import sttp.client3.Response import scala.annotation.unused import scala.concurrent.duration.DurationInt -import scala.concurrent.{ExecutionContext, Future} +import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future} import scala.util.{Failure, Success, Try} trait SearchApiClient { @@ -33,7 +33,7 @@ trait SearchApiClient { @unused private val SearchApiBaseUrl = s"http://$SearchApiHost" - def deleteLearningPathDocument(id: Long, user: Option[TokenUser]): Try[_] = { + def deleteLearningPathDocument(id: Long, user: Option[TokenUser]): Try[?] = { val req = quickRequest .delete(uri"http://$SearchApiHost/intern/learningpath/$id") .readTimeout(IndexTimeout) @@ -41,9 +41,9 @@ trait SearchApiClient { doRawRequest(req, user) } - def indexLearningPathDocument(document: LearningPath, user: Option[TokenUser]): Future[Try[_]] = { - val idString = document.id.map(_.toString).getOrElse("") - implicit val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(1)) + def indexLearningPathDocument(document: LearningPath, user: Option[TokenUser]): Future[Try[?]] = { + val idString = document.id.map(_.toString).getOrElse("") + implicit val ec: ExecutionContextExecutor = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(1)) val future = Future { val body = CirceUtil.toJsonString(document) diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/TaxonomyApiClient.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/TaxonomyApiClient.scala index 92b294994..51bf407aa 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/TaxonomyApiClient.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/integration/TaxonomyApiClient.scala @@ -28,7 +28,7 @@ import scala.concurrent.duration.DurationInt import scala.util.{Failure, Success, Try} trait TaxonomyApiClient { - this: NdlaClient with Props => + this: NdlaClient & Props => val taxonomyApiClient: TaxonomyApiClient class TaxonomyApiClient extends StrictLogging { @@ -251,7 +251,7 @@ trait TaxonomyApiClient { private def get[A: Decoder](url: String, user: Option[TokenUser], params: (String, String)*): Try[A] = { val request = quickRequest - .get(uri"$url".withParams(params: _*)) + .get(uri"$url".withParams(params*)) .readTimeout(taxonomyTimeout) .header(TAXONOMY_VERSION_HEADER, defaultVersion) ndlaClient.fetchWithForwardedAuth[A](request, user) @@ -264,7 +264,7 @@ trait TaxonomyApiClient { params: (String, String)* ): Try[A] = { val request = quickRequest - .put(uri"$url".withParams(params: _*)) + .put(uri"$url".withParams(params*)) .readTimeout(taxonomyTimeout) .body(CirceUtil.toJsonString(data)) .header("content-type", "application/json", replaceExisting = true) @@ -279,7 +279,7 @@ trait TaxonomyApiClient { ): Try[B] = { logger.info(s"Doing call to $url") val request = quickRequest - .put(uri"$url".withParams(params: _*)) + .put(uri"$url".withParams(params*)) .body(CirceUtil.toJsonString(data)) .readTimeout(taxonomyTimeout) .header("content-type", "application/json", replaceExisting = true) @@ -311,7 +311,7 @@ trait TaxonomyApiClient { private[integration] def delete(url: String, user: Option[TokenUser], params: (String, String)*): Try[Unit] = ndlaClient.fetchRawWithForwardedAuth( quickRequest - .delete(uri"$url".withParams(params: _*)) + .delete(uri"$url".withParams(params*)) .readTimeout(taxonomyTimeout), user ) match { diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/model/domain/Sort.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/model/domain/Sort.scala index 2bd1a5d96..6e96dcf69 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/model/domain/Sort.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/model/domain/Sort.scala @@ -48,7 +48,7 @@ object Sort extends Enum[Sort] with CirceEnum[Sort] { private val tsEnumValues: Seq[(String, String)] = values.map(e => e.toString -> e.entryName) implicit val enumTsType: TSNamedType[Sort] = TSType.alias[Sort]( "Sort", - TSEnum.string("LearningpathSortEnum", tsEnumValues: _*) + TSEnum.string("LearningpathSortEnum", tsEnumValues*) ) } diff --git a/learningpath-api/src/main/scala/no/ndla/learningpathapi/validation/DurationValidator.scala b/learningpath-api/src/main/scala/no/ndla/learningpathapi/validation/DurationValidator.scala index 7a31e2e7b..7d27b1b73 100644 --- a/learningpath-api/src/main/scala/no/ndla/learningpathapi/validation/DurationValidator.scala +++ b/learningpath-api/src/main/scala/no/ndla/learningpathapi/validation/DurationValidator.scala @@ -18,9 +18,10 @@ class DurationValidator { durationOpt match { case None => Some(ValidationMessage("duration", DURATION_REQUIRED)) case Some(duration) => - duration < 1 match { - case true => Some(ValidationMessage("duration", DURATION_INVALID)) - case false => None + if (duration < 1) { + Some(ValidationMessage("duration", DURATION_INVALID)) + } else { + None } } }