<commit_before>package models.hms

import models.MongoId
import models.dto.ShowMetaData
import play.Logger
import play.api.libs.json.{JsObject, Json}
import play.modules.reactivemongo.ReactiveMongoPlugin
import play.modules.reactivemongo.json.collection.JSONCollection
import reactivemongo.core.commands.LastError

import play.api.Play.current
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

/**
  * author: cvandrei
  * since: 2016-02-19
  */
case class TranscodeCallback(_id: Option[MongoId],
                             ID: Long,
                             VerboseMessage: Option[String],
                             Status: String,
                             StatusValue: Option[Int],
                             StatusUnit: Option[String],
                             DownloadSource: Option[String],
                             meta: Option[ShowMetaData]
                            )

object TranscodeCallback {

  val transcodeCallCollection = ReactiveMongoPlugin.db.collection[JSONCollection]("hmsTranscode")

  implicit val reads = Json.reads[TranscodeCallback]
  implicit val writes = Json.writes[TranscodeCallback]

  def insert(jobResult: JobResult, meta: ShowMetaData) = {

    val transcodeCallback = TranscodeCallback(None, jobResult.ID, jobResult.VerboseResult, "queued", None, None, None, Some(meta))
    transcodeCallCollection.insert(transcodeCallback) // TODO add error logging/handling

  }

  def findByHmsId(hmsId: Long): Future[Option[TranscodeCallback]] = {
<commit_msg>add explicit return type; delete outdated TODO<commit_after>package models.hms

import models.MongoId
import models.dto.ShowMetaData
import play.Logger
import play.api.libs.json.{JsObject, Json}
import play.modules.reactivemongo.ReactiveMongoPlugin
import play.modules.reactivemongo.json.collection.JSONCollection
import reactivemongo.core.commands.LastError

import play.api.Play.current
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

/**
  * author: cvandrei
  * since: 2016-02-19
  */
case class TranscodeCallback(_id: Option[MongoId],
                             ID: Long,
                             VerboseMessage: Option[String],
                             Status: String,
                             StatusValue: Option[Int],
                             StatusUnit: Option[String],
                             DownloadSource: Option[String],
                             meta: Option[ShowMetaData]
                            )

object TranscodeCallback {

  val transcodeCallCollection = ReactiveMongoPlugin.db.collection[JSONCollection]("hmsTranscode")

  implicit val reads = Json.reads[TranscodeCallback]
  implicit val writes = Json.writes[TranscodeCallback]

  def insert(jobResult: JobResult, meta: ShowMetaData): Future[LastError] = {

    val transcodeCallback = TranscodeCallback(None, jobResult.ID, jobResult.VerboseResult, "queued", None, None, None, Some(meta))
    transcodeCallCollection.insert(transcodeCallback)

  }

  def findByHmsId(hmsId: Long): Future[Option[TranscodeCallback]] = {

{'fraction_non_alphanumeric': 0.08587970408491476, 'fraction_numerical': 0.005146349308459312, 'mean_word_length': 2.8112745098039214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '234686', 'n_tokens_mistral': 852, 'n_tokens_neox': 827, 'n_words': 167}