<commit_before>package lib

import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.MINUTES

import org.kohsuke.github.{GHPullRequest, GHRepository}
import play.api.Logger
import play.api.cache.Cache

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

object Scanner {

  import play.api.Play.current

  def updateFor(site: Site, repoFullName: RepoFullName) {
    val key = repoFullName + " " + site
    Logger.debug(s"update requested for $key")
    Cache.getOrElse(key) {
      new Dogpile(scan(site, Bot.conn().getRepository(repoFullName.text)))
    }.doAtLeastOneMore()
  }

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

    val siteSnapshotF = SiteSnapshot(site)
    val repoSnapshotF = RepoSnapshot(githubRepo)
    val jobFuture = for {
      siteSnapshot <- siteSnapshotF
      repoSnapshot <- repoSnapshotF
      status = DeploymentProgressSnapshot(repoSnapshot, siteSnapshot)
      prStatuses <- status.goCrazy()
    } yield {
      val prByStatus = prStatuses.groupBy(_.currentState)

      Logger.info(s"${githubRepo.getFullName} : All: ${summary(prStatuses)}")
      Logger.info(s"${githubRepo.getFullName} : overdue=${prByStatus.get(Overdue).map(summary)} pending=${prByStatus.get(Pending).map(summary)}")
    }
    Await.ready(jobFuture, Duration(2, MINUTES))
  }

  def summary(prs: Seq[PullRequestSiteCheck]): String = prs.size + " " + prs.map(_.pr.getNumber).sorted.map("#"+_).mkString("(", ", ", ")")
}<commit_msg>Better listing the most recent prs first...<commit_after>package lib

import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.MINUTES

import org.kohsuke.github.{GHPullRequest, GHRepository}
import play.api.Logger
import play.api.cache.Cache

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

object Scanner {

  import play.api.Play.current

  def updateFor(site: Site, repoFullName: RepoFullName) {
    val key = repoFullName + " " + site
    Logger.debug(s"update requested for $key")
    Cache.getOrElse(key) {
      new Dogpile(scan(site, Bot.conn().getRepository(repoFullName.text)))
    }.doAtLeastOneMore()
  }

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

    val siteSnapshotF = SiteSnapshot(site)
    val repoSnapshotF = RepoSnapshot(githubRepo)
    val jobFuture = for {
      siteSnapshot <- siteSnapshotF
      repoSnapshot <- repoSnapshotF
      status = DeploymentProgressSnapshot(repoSnapshot, siteSnapshot)
      prStatuses <- status.goCrazy()
    } yield {
      val prByStatus = prStatuses.groupBy(_.currentState)

      Logger.info(s"${githubRepo.getFullName} : All: ${summary(prStatuses)}")
      Logger.info(s"${githubRepo.getFullName} : overdue=${prByStatus.get(Overdue).map(summary)} pending=${prByStatus.get(Pending).map(summary)}")
    }
    Await.ready(jobFuture, Duration(2, MINUTES))
  }

  def summary(prs: Seq[PullRequestSiteCheck]): String = prs.size + " " + prs.map(_.pr.getNumber).sorted.reverse.map("#"+_).mkString("(", ", ", ")")
}
{'fraction_non_alphanumeric': 0.13082437275985664, 'fraction_numerical': 0.0005973715651135006, 'mean_word_length': 4.499178981937603, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '313813', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1071, 'n_words': 188}