<commit_before>package lila.user

import lila.db.dsl._
import org.joda.time.DateTime

case class Note(
    _id: String,
    from: User.ID,
    to: User.ID,
    text: String,
    mod: Boolean,
    dox: Boolean,
    date: DateTime
) {
  def userIds            = List(from, to)
  def isFrom(user: User) = user.id == from
}

case class UserNotes(user: User, notes: List[Note])

final class NoteApi(
    userRepo: UserRepo,
    coll: Coll
)(implicit
    ec: scala.concurrent.ExecutionContext,
    ws: play.api.libs.ws.StandaloneWSClient
) {

  import reactivemongo.api.bson._
  import lila.db.BSON.BSONJodaDateTimeHandler
  implicit private val noteBSONHandler = Macros.handler[Note]

  def get(user: User, me: User, isMod: Boolean): Fu[List[Note]] =
    coll
      .find(
        $doc("to" -> user.id) ++ {
          if (isMod)
            $or(
              $doc("from" -> me.id),
              $doc("mod"  -> true)
            )
          else $doc("from" -> me.id)
        }
      )
      .sort($sort desc "date")
      .cursor[Note]()
      .list(20)

  def byUserForMod(id: User.ID): Fu[List[Note]] =
    coll
      .find($doc("to" -> id, "mod" -> true))
      .sort($sort desc "date")
      .cursor[Note]()
      .list(50)

  def byUsersForMod(ids: List[User.ID]): Fu[List[Note]] =
    coll<commit_msg>Hide their own mod notes to legacy mods<commit_after>package lila.user

import lila.db.dsl._
import org.joda.time.DateTime

case class Note(
    _id: String,
    from: User.ID,
    to: User.ID,
    text: String,
    mod: Boolean,
    dox: Boolean,
    date: DateTime
) {
  def userIds            = List(from, to)
  def isFrom(user: User) = user.id == from
}

case class UserNotes(user: User, notes: List[Note])

final class NoteApi(
    userRepo: UserRepo,
    coll: Coll
)(implicit
    ec: scala.concurrent.ExecutionContext,
    ws: play.api.libs.ws.StandaloneWSClient
) {

  import reactivemongo.api.bson._
  import lila.db.BSON.BSONJodaDateTimeHandler
  implicit private val noteBSONHandler = Macros.handler[Note]

  def get(user: User, me: User, isMod: Boolean): Fu[List[Note]] =
    coll
      .find(
        $doc("to" -> user.id) ++ {
          if (isMod)
            $or(
              $doc("from" -> me.id),
              $doc("mod"  -> true)
            )
          else
            $doc("from" -> me.id, "mod" -> false)
        }
      )
      .sort($sort desc "date")
      .cursor[Note]()
      .list(20)

  def byUserForMod(id: User.ID): Fu[List[Note]] =
    coll
      .find($doc("to" -> id, "mod" -> true))
      .sort($sort desc "date")
      .cursor[Note]()
      .list(50)

  def byUsersForMod(ids: List[User.ID]): Fu[List[Note]] =
    coll
{'fraction_non_alphanumeric': 0.14913598797896319, 'fraction_numerical': 0.003005259203606311, 'mean_word_length': 2.208433734939759, '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': '1194180', 'n_tokens_mistral': 959, 'n_tokens_neox': 946, 'n_words': 218}