<commit_before>package info.rori.lunchbox.server.akka.scala.service.api.v1

import akka.http.marshallers.sprayjson.SprayJsonSupport._
import akka.http.marshalling.ToResponseMarshallable
import akka.pattern.ask
import info.rori.lunchbox.server.akka.scala.domain.model.LunchProvider
import info.rori.lunchbox.server.akka.scala.domain.service.LunchProviderService._
import info.rori.lunchbox.server.akka.scala.service.HttpRoute
import spray.json._

import scala.concurrent.Future


/**
 * Model für LunchProvider in API v1.
 */
private[v1] case class LunchProvider_ApiV1(id: Int,
                                           name: String,
                                           location: String)

private[v1] case object LunchProvider_ApiV1 {
  def apply(p: LunchProvider): LunchProvider_ApiV1 = apply(id = p.id, name = p.name, location = p.location)
}

private[v1] object LunchProviderJsonSupport extends DefaultJsonProtocol {
  implicit val lunchProviderFormat = jsonFormat3(LunchProvider_ApiV1.apply)
  implicit val printer: spray.json.JsonPrinter = CompactPrinter // remove line, if you want to print pretty JSON
}


/**
 * HTTP-Route für LunchProvider in API v1.
 */
trait LunchProviderRoute_ApiV1
  extends HttpRoute {

  import LunchProviderJsonSupport._

  private def domainService = context.actorSelection("/user/app/domain/LunchProviderService")

  val lunchProviderRoute =
    path("lunchProvider") {
      (get & parameters('location.?)) { optLocation =>
        complete {
          val domainMsg = optLocation match {
            case Some(location) => GetByLocation(location)
            case None => GetAll
          }
          domainService.ask(domainMsg).mapTo[MultiResult]
            .mapSeqToResponse(domainResMsg => domainResMsg.providers)
            .recoverOnError(s"api/v1/lunchProvider?location=$optLocation")
        }
      }
    } ~
    path("lunchProvider" / IntNumber) { id =>
      get {
        complete {<commit_msg>kleine Umbenennung<commit_after>package info.rori.lunchbox.server.akka.scala.service.api.v1

import akka.http.marshallers.sprayjson.SprayJsonSupport._
import akka.http.marshalling.ToResponseMarshallable
import akka.pattern.ask
import info.rori.lunchbox.server.akka.scala.domain.model.LunchProvider
import info.rori.lunchbox.server.akka.scala.domain.service.LunchProviderService._
import info.rori.lunchbox.server.akka.scala.service.HttpRoute
import spray.json._

import scala.concurrent.Future


/**
 * Model für LunchProvider in API v1.
 */
private[v1] case class LunchProvider_ApiV1(id: Int,
                                           name: String,
                                           location: String)

private[v1] case object LunchProvider_ApiV1 {
  def apply(p: LunchProvider): LunchProvider_ApiV1 = apply(id = p.id, name = p.name, location = p.location)
}

private[v1] object LunchProviderJsonSupport extends DefaultJsonProtocol {
  implicit val lunchProviderFormat = jsonFormat3(LunchProvider_ApiV1.apply)
  implicit val printer: spray.json.JsonPrinter = CompactPrinter // remove line, if you want to print pretty JSON
}


/**
 * HTTP-Route für LunchProvider in API v1.
 */
trait LunchProviderRoute_ApiV1
  extends HttpRoute {

  import LunchProviderJsonSupport._

  private def domainService = context.actorSelection("/user/app/domain/LunchProviderService")

  val lunchProviderRoute =
    path("lunchProvider") {
      (get & parameters('location.?)) { optLocation =>
        complete {
          val domainReqMsg = optLocation match {
            case Some(location) => GetByLocation(location)
            case None => GetAll
          }
          domainService.ask(domainReqMsg).mapTo[MultiResult]
            .mapSeqToResponse(domainResMsg => domainResMsg.providers)
            .recoverOnError(s"api/v1/lunchProvider?location=$optLocation")
        }
      }
    } ~
    path("lunchProvider" / IntNumber) { id =>
      get {
        complete {
{'fraction_non_alphanumeric': 0.09399744572158365, 'fraction_numerical': 0.0066411238825031926, 'mean_word_length': 3.122105263157895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5401636', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1150, 'n_words': 225}