<commit_before>package controllers

import play.api.mvc._
import macros._
import dbrary._
import site._
import models._

object SiteApi extends SiteController {
  private final val startTime = new Timestamp

  private final val constantsJson = JsonObject(
      'permision -> Permission.values.view.map(_.toString)
    , 'consent -> Consent.values.view.map(c =>
	JsonObject.flatten(
	  Some('name -> c.toString)
	, Consent.description(c).map('message -> _)
	)
      )
    , 'classification -> Classification.values.view.map(_.toString)
    , 'record_category -> JsonRecord.map[RecordCategory](_.json)(RecordCategory.getAll)
    ).js
  private final val constantsETag = "constants:" + constantsJson.hashCode
  private final val constantsResult = Ok(constantsJson)
    .withHeaders(
      LAST_MODIFIED -> HTTP.date(startTime)
    , ETAG -> HTTP.quote(constantsETag)
    , CACHE_CONTROL -> "max-age=86400"
    )
  def constants = Action { implicit request =>
    if (HTTP.notModified(constantsETag, startTime)) NotModified
    else constantsResult
  }
}
<commit_msg>Unify api constants to records<commit_after>package controllers

import play.api.mvc._
import macros._
import dbrary._
import site._
import models._

object SiteApi extends SiteController {
  private final val startTime = new Timestamp

  private final val constantsJson = JsonObject(
      'permission -> JsonRecord.map[Permission.Value](c => JsonRecord(c.id
	, 'name -> c.toString
	))(Permission.values.toSeq)
    , 'consent -> JsonRecord.map[Consent.Value](c => JsonRecord.flatten(c.id
	, Some('name -> c.toString)
	, Consent.description(c).map('message -> _)
	))(Consent.values.toSeq)
    , 'classification -> JsonRecord.map[Classification.Value](c => JsonRecord(c.id
	, 'name -> c.toString
	))(Classification.values.toSeq)
    // to be consistent with volume."categories":
    , 'categories -> JsonRecord.map[RecordCategory](_.json)(RecordCategory.getAll)
    ).js
  private final val constantsETag = "constants:" + constantsJson.hashCode
  private final val constantsResult = Ok(constantsJson)
    .withHeaders(
      LAST_MODIFIED -> HTTP.date(startTime)
    , ETAG -> HTTP.quote(constantsETag)
    , CACHE_CONTROL -> "max-age=86400"
    )
  def constants = Action { implicit request =>
    if (HTTP.notModified(constantsETag, startTime)) NotModified
    else constantsResult
  }
}

{'fraction_non_alphanumeric': 0.11942201444963876, 'fraction_numerical': 0.004249893752656183, 'mean_word_length': 3.9557894736842107, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 29, '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': '2067303', 'n_tokens_mistral': 724, 'n_tokens_neox': 712, 'n_words': 156}