<commit_before>/*
 * Copyright 2014 The Guardian
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package controllers

import com.netaporter.uri.Uri
import lib._
import org.kohsuke.github.GHRepository
import play.api.Logger
import play.api.cache.Cache
import play.api.mvc._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}

object Application extends Controller {

  import play.api.Play.current

  def githubHook(siteUrl: String, siteLabel: Option[String]) = Action(parse.json(maxLength = 20 * 1024)) { request =>
    val site = Site.from(Uri.parse(siteUrl), siteLabel)
    for (repoFullName <- (request.body \ "repository" \ "full_name").validate[String]) {

      Cache.getOrElse(repoFullName +"/"+ site) {
        new Dogpile(scan(site, Bot.conn().getRepository(repoFullName)))
      }.doAtLeastOneMore()
    }
    NoContent
  }

  def updateRepo(orgName: String, repoName: String, siteUrl: String, siteLabel: Option[String]) = Action { implicit req =>
    val site = Site.from(Uri.parse(siteUrl), siteLabel)
    Cache.getOrElse(orgName + "/" +repoName +"/" + site) {
      new Dogpile(scan(site, Bot.conn().getOrganization(orgName).getRepository(repoName)))
    }.doAtLeastOneMore()

    NoContent
  }

  def scan(site: Site, githubRepo: GHRepository) = {
    Logger.info(s"Asked to audit ${githubRepo.getFullName}")

    val jobFuture = for {
      siteSnapshot <- SiteSnapshot(site)
      repoSnapshot <- RepoSnapshot(githubRepo)
    } yield {
      Logger.info(s"about to get status...")
      val status = DeploymentProgressSnapshot(repoSnapshot, siteSnapshot)
      Logger.info(s"got status...")

      status.goCrazy()
      Logger.info(s"finished I think.")
    }
    Await.ready(jobFuture, Duration.Inf)
  }

  def index = Action { implicit req =>
    Ok(views.html.userPages.index())
  }

}
<commit_msg>I've now seen pull-request-event payloads at about 25K in size<commit_after>/*
 * Copyright 2014 The Guardian
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package controllers

import com.netaporter.uri.Uri
import lib._
import org.kohsuke.github.GHRepository
import play.api.Logger
import play.api.cache.Cache
import play.api.mvc._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}

object Application extends Controller {

  import play.api.Play.current

  def githubHook(siteUrl: String, siteLabel: Option[String]) = Action(parse.json(maxLength = 128 * 1024)) { request =>
    val site = Site.from(Uri.parse(siteUrl), siteLabel)
    for (repoFullName <- (request.body \ "repository" \ "full_name").validate[String]) {

      Cache.getOrElse(repoFullName +"/"+ site) {
        new Dogpile(scan(site, Bot.conn().getRepository(repoFullName)))
      }.doAtLeastOneMore()
    }
    NoContent
  }

  def updateRepo(orgName: String, repoName: String, siteUrl: String, siteLabel: Option[String]) = Action { implicit req =>
    val site = Site.from(Uri.parse(siteUrl), siteLabel)
    Cache.getOrElse(orgName + "/" +repoName +"/" + site) {
      new Dogpile(scan(site, Bot.conn().getOrganization(orgName).getRepository(repoName)))
    }.doAtLeastOneMore()

    NoContent
  }

  def scan(site: Site, githubRepo: GHRepository) = {
    Logger.info(s"Asked to audit ${githubRepo.getFullName}")

    val jobFuture = for {
      siteSnapshot <- SiteSnapshot(site)
      repoSnapshot <- RepoSnapshot(githubRepo)
    } yield {
      Logger.info(s"about to get status...")
      val status = DeploymentProgressSnapshot(repoSnapshot, siteSnapshot)
      Logger.info(s"got status...")

      status.goCrazy()
      Logger.info(s"finished I think.")
    }
    Await.ready(jobFuture, Duration.Inf)
  }

  def index = Action { implicit req =>
    Ok(views.html.userPages.index())
  }

}

{'fraction_non_alphanumeric': 0.11376633986928104, 'fraction_numerical': 0.006331699346405229, 'mean_word_length': 3.74515503875969, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1665144', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1436, 'n_words': 405}