<commit_before>package models

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import macros._
import dbrary._
import site._

/** Link between Authorize (rows in table/view) and Access. */
sealed class Authorization (val child : Party, val parent : Party, val inherit : Permission.Value, val direct : Permission.Value) extends Access with TableRow {
  final def childId = child.id
  final def parentId = parent.id
  private[models] def sqlKey = SQLTerms('child -> childId, 'parent -> parentId)

  final def target = parent
  final def identity = child
  final val group = inherit
}

/** A specific authorization by one party of another.
  * An authorization represents granting of certain permissions to a party by/under another, which can also be viewed as group membership.
  * Unlike most [TableRow] classes, these may be constructed directly, and thus are not expected to reflect the current state of the database in the same way and have different update semantics.
  * @constructor create an authorization object, not (yet) persisted to the database
  * @param child the party being authorized, the "member"
  * @param parent the party whose permissions are being authorized, the "group"
  * @param inherit the level of site/group access granted via the parent to the child, thus the maximum site permission level inherited by the child from the parent
  * @param direct the specific permissions granted on behalf of the parent to the child, such that the child has rights to perform actions up to this permission as the parent (not inherited)
  * @param authorized the time at which this authorization takes/took effect, or never (not yet) if None
  * @param expires the time at which this authorization stops, or never if None
  */
final class Authorize protected (child : Party, parent : Party, inherit : Permission.Value, direct : Permission.Value, val authorized : Option[Timestamp], val expires : Option[Timestamp], val info : Option[String]) extends Authorization(child, parent, inherit, direct) {
  /** Determine if this authorization is currently in effect.
    * @return true if authorized is set and in the past, and expires is unset or in the future */
  def valid =
    authorized.exists(_.toDateTime.isBeforeNow) && expires.forall(_.toDateTime.isAfterNow)

  def json = JsonObject.flatten(
    Some('inherit -> inherit),
    Some('direct -> direct),
    authorized.map('authorized -> _),
    expires.map('expires -> _)
  )
}<commit_msg>Add info to authorize json<commit_after>package models

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import macros._
import dbrary._
import site._

/** Link between Authorize (rows in table/view) and Access. */
sealed class Authorization (val child : Party, val parent : Party, val inherit : Permission.Value, val direct : Permission.Value) extends Access with TableRow {
  final def childId = child.id
  final def parentId = parent.id
  private[models] def sqlKey = SQLTerms('child -> childId, 'parent -> parentId)

  final def target = parent
  final def identity = child
  final val group = inherit
}

/** A specific authorization by one party of another.
  * An authorization represents granting of certain permissions to a party by/under another, which can also be viewed as group membership.
  * Unlike most [TableRow] classes, these may be constructed directly, and thus are not expected to reflect the current state of the database in the same way and have different update semantics.
  * @constructor create an authorization object, not (yet) persisted to the database
  * @param child the party being authorized, the "member"
  * @param parent the party whose permissions are being authorized, the "group"
  * @param inherit the level of site/group access granted via the parent to the child, thus the maximum site permission level inherited by the child from the parent
  * @param direct the specific permissions granted on behalf of the parent to the child, such that the child has rights to perform actions up to this permission as the parent (not inherited)
  * @param authorized the time at which this authorization takes/took effect, or never (not yet) if None
  * @param expires the time at which this authorization stops, or never if None
  */
final class Authorize protected (child : Party, parent : Party, inherit : Permission.Value, direct : Permission.Value, val authorized : Option[Timestamp], val expires : Option[Timestamp], val info : Option[String]) extends Authorization(child, parent, inherit, direct) {
  /** Determine if this authorization is currently in effect.
    * @return true if authorized is set and in the past, and expires is unset or in the future */
  def valid =
    authorized.exists(_.toDateTime.isBeforeNow) && expires.forall(_.toDateTime.isAfterNow)

  def json = JsonObject.flatten(
    Some('inherit -> inherit),
    Some('direct -> direct),
    authorized.map('authorized -> _),
    expires.map('expires -> _),
    info.map('info -> _)
  )
}
{'fraction_non_alphanumeric': 0.07463868540882994, 'fraction_numerical': 0.0, 'mean_word_length': 4.27348643006263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '7118610', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1227, 'n_words': 621}