<commit_before>package controllers

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api._
import          templates.Html
import          Play.current
import          mvc._
import          data._
import play.api.i18n.Messages
import play.api.libs.json
import macros._
import macros.async._
import site._
import dbrary._
import models._

private[controllers] abstract sealed class RecordController extends ObjectController[Record] {
  protected def action(i : models.Record.Id, p : Permission.Value = Permission.VIEW) =
    RequestObject.check(models.Record.get(i)(_), p)

  protected def Action(i : models.Record.Id, p : Permission.Value = Permission.VIEW) =
    SiteAction andThen action(i, p)

  protected final val categoryMapping : Mapping[RecordCategory] =
    Forms.of[RecordCategory.Id]
      .transform[Option[RecordCategory]](RecordCategory.get(_), _.get.id)
      .verifying(Messages("error.invalid"), _.isDefined)
      .transform(_.get, Some(_))
  protected final val metricMapping : Mapping[Metric[_]] =
    Forms.of[Metric.Id]
      .transform[Option[Metric[_]]](Metric.get(_), _.get.id)
      .verifying(Messages("error.invalid"), _.isDefined)
      .transform(_.get, Some(_))

  private[this] def editResult(record : Record)(implicit request : SiteRequest[_]) : Result =
    if (request.isApi) result(record)
    else Redirect(routes.RecordHtml.edit(record.id))

  private[this] def updateMeasure(record : Record, metric : Metric[_], datum : Option[String]) =
    datum.fold(
      record.removeMeasure(metric))(
      d => record.setMeasure(new Measure(metric, d)))

  def update(i : models.Record.Id) =
    Action(i, Permission.EDIT).async { implicit request =>
      val form = new RecordController.EditForm()._bind<commit_msg>Don't treat remove empty measure as error<commit_after>package controllers

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api._
import          templates.Html
import          Play.current
import          mvc._
import          data._
import play.api.i18n.Messages
import play.api.libs.json
import macros._
import macros.async._
import site._
import dbrary._
import models._

private[controllers] abstract sealed class RecordController extends ObjectController[Record] {
  protected def action(i : models.Record.Id, p : Permission.Value = Permission.VIEW) =
    RequestObject.check(models.Record.get(i)(_), p)

  protected def Action(i : models.Record.Id, p : Permission.Value = Permission.VIEW) =
    SiteAction andThen action(i, p)

  protected final val categoryMapping : Mapping[RecordCategory] =
    Forms.of[RecordCategory.Id]
      .transform[Option[RecordCategory]](RecordCategory.get(_), _.get.id)
      .verifying(Messages("error.invalid"), _.isDefined)
      .transform(_.get, Some(_))
  protected final val metricMapping : Mapping[Metric[_]] =
    Forms.of[Metric.Id]
      .transform[Option[Metric[_]]](Metric.get(_), _.get.id)
      .verifying(Messages("error.invalid"), _.isDefined)
      .transform(_.get, Some(_))

  private[this] def editResult(record : Record)(implicit request : SiteRequest[_]) : Result =
    if (request.isApi) result(record)
    else Redirect(routes.RecordHtml.edit(record.id))

  private[this] def updateMeasure(record : Record, metric : Metric[_], datum : Option[String]) =
    datum.fold(
      record.removeMeasure(metric).map(_ => true))(
      d => record.setMeasure(new Measure(metric, d)))

  def update(i : models.Record.Id) =
    Action(i, Permission.EDIT).async { implicit request =>
      val form = new RecordController.EditForm()._bind
{'fraction_non_alphanumeric': 0.12305168170631665, 'fraction_numerical': 0.0010937927262783702, 'mean_word_length': 4.024725274725275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '4910509', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1052, 'n_words': 242}