<commit_before>package uk.ac.wellcome.platform.idminter.database

import com.google.inject.Inject
import com.twitter.inject.Logging
import scalikejdbc._
import uk.ac.wellcome.platform.idminter.model.{Identifier, IdentifiersTable}
import uk.ac.wellcome.utils.GlobalExecutionContext.context

import scala.concurrent.{Future, blocking}


class IdentifiersDao @Inject()(db: DB, identifiers: IdentifiersTable) extends Logging {

  //  private val identifiersTableName = dynamoConfig.table
  implicit val session = AutoSession(db.settingsProvider)

  def findSourceIdInDb(miroId: String): Future[Option[Identifier]] =
    Future {
      blocking {
        info(s"About to search for MiroID $miroId in Identifiers")
        val i = identifiers.i
        withSQL {
          select.from(identifiers as i).where.eq(i.MiroID, miroId)
        }.map(Identifier(i)).single.apply()
      }
    } recover {
      case e: Throwable =>
        error(s"Failed getting MiroID $miroId in DynamoDB", e)
        throw e
    }

  def saveIdentifier(identifier: Identifier): Future[Unit] = {
    val insertIntoDbFuture = Future {
      blocking {
        info(s"putting new identifier $identifier")
        withSQL {
          insert
            .into(identifiers)
            .namedValues(identifiers.column.CanonicalID -> identifier.CanonicalID,
              identifiers.column.MiroID -> identifier.MiroID)
        }.update().apply()
        ()<commit_msg>Remove leftover comment<commit_after>package uk.ac.wellcome.platform.idminter.database

import com.google.inject.Inject
import com.twitter.inject.Logging
import scalikejdbc._
import uk.ac.wellcome.platform.idminter.model.{Identifier, IdentifiersTable}
import uk.ac.wellcome.utils.GlobalExecutionContext.context

import scala.concurrent.{Future, blocking}


class IdentifiersDao @Inject()(db: DB, identifiers: IdentifiersTable) extends Logging {

  implicit val session = AutoSession(db.settingsProvider)

  def findSourceIdInDb(miroId: String): Future[Option[Identifier]] =
    Future {
      blocking {
        info(s"About to search for MiroID $miroId in Identifiers")
        val i = identifiers.i
        withSQL {
          select.from(identifiers as i).where.eq(i.MiroID, miroId)
        }.map(Identifier(i)).single.apply()
      }
    } recover {
      case e: Throwable =>
        error(s"Failed getting MiroID $miroId in DynamoDB", e)
        throw e
    }

  def saveIdentifier(identifier: Identifier): Future[Unit] = {
    val insertIntoDbFuture = Future {
      blocking {
        info(s"putting new identifier $identifier")
        withSQL {
          insert
            .into(identifiers)
            .namedValues(identifiers.column.CanonicalID -> identifier.CanonicalID,
              identifiers.column.MiroID -> identifier.MiroID)
        }.update().apply()
        ()
{'fraction_non_alphanumeric': 0.10141843971631205, 'fraction_numerical': 0.0, 'mean_word_length': 3.047345767575323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2774220', 'n_tokens_mistral': 830, 'n_tokens_neox': 816, 'n_words': 174}