<commit_before>package lila.analyse

import lila.db.api._
import lila.db.Implicits._
import tube.analysisTube

import play.api.libs.json.Json

import org.joda.time.DateTime
import org.scala_tools.time.Imports._

private[analyse] object AnalysisRepo {

  type ID = String

  def done(id: ID, a: Analysis) = $update(
    $select(id),
    $set(Json.obj(
      "done" -> true,
      "encoded" -> a.encodeInfos
    )) ++ $unset("fail")
  )

  def fail(id: ID, err: Exception) = $update.field(id, "fail", err.getMessage)

  def progress(id: ID, userId: ID) = $update(
    $select(id),
    $set(Json.obj(
      "uid" -> userId,
      "done" -> false,
      "date" -> $date(DateTime.now)
    ) ++ $unset("fail")),
    upsert = true)

  def doneById(id: ID): Fu[Option[Analysis]] =<commit_msg>fix analysis db query<commit_after>package lila.analyse

import lila.db.api._
import lila.db.Implicits._
import tube.analysisTube

import play.api.libs.json.Json

import org.joda.time.DateTime
import org.scala_tools.time.Imports._

private[analyse] object AnalysisRepo {

  type ID = String

  def done(id: ID, a: Analysis) = $update(
    $select(id),
    $set(Json.obj(
      "done" -> true,
      "encoded" -> a.encodeInfos
    )) ++ $unset("fail")
  )

  def fail(id: ID, err: Exception) = $update.field(id, "fail", err.getMessage)

  def progress(id: ID, userId: ID) = $update(
    $select(id),
    $set(Json.obj(
      "uid" -> userId,
      "done" -> false,
      "date" -> $date(DateTime.now)
    )) ++ $unset("fail"),
    upsert = true)

  def doneById(id: ID): Fu[Option[Analysis]] =
{'fraction_non_alphanumeric': 0.16751269035532995, 'fraction_numerical': 0.0, 'mean_word_length': 3.171957671957672, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6949755', 'n_tokens_mistral': 585, 'n_tokens_neox': 578, 'n_words': 127}