<commit_before>package app.restlike.demo

import app.ServiceFactory._
import im.mange.reprobate.api.Runner
import im.mange.shoreditch.api.Check
import net.liftweb.http.rest.RestHelper
import net.liftweb.http.{GetRequest, Req}
import org.joda.time.LocalDateTime

//TODO: use new RestHelper
object Demo extends RestHelper {
  val demoCounter = DemoCounter()

  serve {
    case Req("demo" :: "success" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(AlwaysPassProbe) }
    case Req("demo" :: "failure" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(FailureProbe) }
    case Req("demo" :: "flipflop" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(FlipFloppingProbe) }
    case Req("demo" :: "oddevenminute" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(OddFailureEvenSuccessMinuteProbe) }
    case Req("demo" :: "oddevenhour" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(OddFailureEvenSuccessHourProbe) }
    case Req("demo" :: "failureafter" :: after :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(FailureAfter(Integer.parseInt(after), demoCounter)) }
    case Req("demo" :: "slow" :: sleepSeconds :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(SlowProbe(Integer.parseInt(sleepSeconds))) }
  }
}

case class DemoCounter() {
  private var count = 0

  def next = synchronized {
    count += 1
    count
  }
}

object AlwaysPassProbe extends Check {
  def run = success
}

case object FailureProbe extends Check {
  def run = failure(List("I always let myself down"))
}

case object FlipFloppingProbe extends Check {
  private var imAFailure = true

  def run = {
    imAFailure = !imAFailure
    if (imAFailure) failure(List("I let myself down every other time")) else success
  }
}

case object OddFailureEvenSuccessMinuteProbe extends Check {
  def run = if (isEven) success else failure(List("Every other minute I feel odd, then I let myself down: " + minute))

  private def minute = systemClock().dateTime.getMinuteOfHour
  private def isEven = minute % 2 == 0<commit_msg>create a check with a massive message to repeats timt's issue<commit_after>package app.restlike.demo

import app.ServiceFactory._
import im.mange.reprobate.api.Runner
import im.mange.shoreditch.api.Check
import net.liftweb.http.rest.RestHelper
import net.liftweb.http.{GetRequest, Req}
import org.joda.time.LocalDateTime

//TODO: use new RestHelper
object Demo extends RestHelper {
  val demoCounter = DemoCounter()

  serve {
    case Req("demo" :: "success" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(AlwaysPassProbe) }
    case Req("demo" :: "failure" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(FailureProbe) }
    case Req("demo" :: "longmessage" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(LongMessageProbe) }
    case Req("demo" :: "flipflop" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(FlipFloppingProbe) }
    case Req("demo" :: "oddevenminute" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(OddFailureEvenSuccessMinuteProbe) }
    case Req("demo" :: "oddevenhour" :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(OddFailureEvenSuccessHourProbe) }
    case Req("demo" :: "failureafter" :: after :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(FailureAfter(Integer.parseInt(after), demoCounter)) }
    case Req("demo" :: "slow" :: sleepSeconds :: Nil, _, GetRequest) ⇒ () ⇒ { Runner.run(SlowProbe(Integer.parseInt(sleepSeconds))) }
  }
}

case class DemoCounter() {
  private var count = 0

  def next = synchronized {
    count += 1
    count
  }
}

object AlwaysPassProbe extends Check {
  def run = success
}

case object FailureProbe extends Check {
  def run = failure(List("I always let myself down"))
}

case object LongMessageProbe extends Check {
  def run = failure(List(
    "reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongmessage",
    "detaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetaildetail"
  ))
}

case object FlipFloppingProbe extends Check {
  private var imAFailure = true

  def run = {
    imAFailure = !imAFailure
    if (imAFailure) failure(List("I let myself down every other time")) else success
  }
}

case object OddFailureEvenSuccessMinuteProbe extends Check {
  def run = if (isEven) success else failure(List("Every other minute I feel odd, then I let myself down: " + minute))

  private def minute = systemClock().dateTime.getMinuteOfHour
  private def isEven = minute % 2 == 0
{'fraction_non_alphanumeric': 0.05382298649567668, 'fraction_numerical': 0.0007772272418148256, 'mean_word_length': 11.948427672955974, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6261055', 'n_tokens_mistral': 2966, 'n_tokens_neox': 2430, 'n_words': 377}