<commit_before>package io.flow.oneapi

import com.bryzek.apidoc.spec.v0.models.Service
import io.flow.build.{Application, BuildType, Downloader}

case class Controller() extends io.flow.build.Controller {

  override val name = "OneApi"
  override val command = "oneapi"

  def run(
    buildType: BuildType,
    downloader: Downloader,
    services: Seq[Service]
  ) (
    implicit ec: scala.concurrent.ExecutionContext
  ) {
    val eventService: Seq[Service] = buildType match {
      case BuildType.Api | BuildType.ApiInternal => Seq(
        downloader.service(Application("flow", buildType.toString, "latest")) match {
          case Left(errors) => sys.error(s"Failed to download events: $errors")
          case Right(service) => service
        }
      )
      case BuildType.ApiEvent | BuildType.ApiInternalEvent => Nil
    }
    
    println("Building single API from: " + services.map(_.name).mkString(", "))
    OneApi(buildType, services ++ eventService).process match {
      case Left(errs) => {
        errs.foreach { addError(_) }
      }

      case Right(service) => {
        import com.bryzek.apidoc.spec.v0.models.json._
        import play.api.libs.json._

        val path = s"/tmp/flow-${buildType}.json"
        new java.io.PrintWriter(path) { write(Json.prettyPrint(Json.toJson(service))); close }
        println(s"One API file created. See: $path")
      }
    }
  }

}
<commit_msg>Pull in api events to oneapi<commit_after>package io.flow.oneapi

import com.bryzek.apidoc.spec.v0.models.Service
import io.flow.build.{Application, BuildType, Downloader}

case class Controller() extends io.flow.build.Controller {

  override val name = "OneApi"
  override val command = "oneapi"

  def run(
    buildType: BuildType,
    downloader: Downloader,
    services: Seq[Service]
  ) (
    implicit ec: scala.concurrent.ExecutionContext
  ) {
    val eventService: Seq[Service] = (
      buildType match {
        case BuildType.ApiEvent | BuildType.ApiInternalEvent => None
        case BuildType.Api => Some(BuildType.ApiEvent.toString)
        case BuildType.ApiInternal => Some(BuildType.ApiInternalEvent.toString)
      }
    ) match {
      case None => Nil
      case Some(name) => downloader.service(Application("flow", name, "latest")) match {
        case Left(errors) => sys.error(s"Failed to download apidoc application flow/$name: $errors")
        case Right(service) => Seq(service)
      }
    }

    val all = services ++ eventService
    println("Building single API from: " + all.map(_.name).mkString(", "))
    OneApi(buildType, all).process match {
      case Left(errs) => {
        errs.foreach { addError(_) }
      }

      case Right(service) => {
        import com.bryzek.apidoc.spec.v0.models.json._
        import play.api.libs.json._

        val path = s"/tmp/flow-${buildType}.json"
        new java.io.PrintWriter(path) { write(Json.prettyPrint(Json.toJson(service))); close }
        println(s"One API file created. See: $path")
      }
    }
  }

}

{'fraction_non_alphanumeric': 0.12533244680851063, 'fraction_numerical': 0.0013297872340425532, 'mean_word_length': 2.8825806451612905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3946369', 'n_tokens_mistral': 945, 'n_tokens_neox': 922, 'n_words': 200}