<commit_before>package models

import awswrappers.dynamodb._
import com.amazonaws.services.dynamodbv2.model.{AttributeValue, QueryRequest}
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import play.api.libs.json.Json

import scala.collection.JavaConverters._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

case class InsertMetric(date: String, hits: Int)

object InsertMetric {
  implicit val signupMetricWrites = Json.writes[InsertMetric]
}

object RawStats {
  val TableName = "email-signup-stats"

  val listIdAndNames = Map[Int, String](
    37 -> "UK Today",
    1493 -> "US Today",
    1506 -> "AU Today",
    3573 -> "The Minute")

  //Aim of class is to convert directly to JSON used by highcharts
  case class InsertMetricGraphStructure(
    name: String,
    visible: Boolean,
    //Inner list items are tuples (date, hits)
    data: List[List[Long]])

  object InsertMetricGraphStructure {
    implicit val insertMetricGraphStructureWrites = Json.writes[InsertMetricGraphStructure]
  }

  def getRawStatsFor(listId: Int): Future[List[InsertMetric]] = {
    val queryRequest = new QueryRequest()
      .withTableName(TableName)
      .withKeyConditionExpression("list_id = :listId")
      .withExpressionAttributeValues(
        Map(":listId" -> new AttributeValue().withN(listId.toString)).asJava)

    dynamoDbClient.queryFuture(queryRequest).map{ queryResult =>
      queryResult.getItems.asScala.toList
        .map(_.asScala)
        .flatMap { attributeMap =>
          for {
            hits <- attributeMap.get("hits").map(_.getN)<commit_msg>Change to correct ID<commit_after>package models

import awswrappers.dynamodb._
import com.amazonaws.services.dynamodbv2.model.{AttributeValue, QueryRequest}
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import play.api.libs.json.Json

import scala.collection.JavaConverters._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

case class InsertMetric(date: String, hits: Int)

object InsertMetric {
  implicit val signupMetricWrites = Json.writes[InsertMetric]
}

object RawStats {
  val TableName = "email-signup-stats"

  val listIdAndNames = Map[Int, String](
    37 -> "UK Today",
    1493 -> "US Today",
    1506 -> "AU Today",
    3599 -> "The Minute")

  //Aim of class is to convert directly to JSON used by highcharts
  case class InsertMetricGraphStructure(
    name: String,
    visible: Boolean,
    //Inner list items are tuples (date, hits)
    data: List[List[Long]])

  object InsertMetricGraphStructure {
    implicit val insertMetricGraphStructureWrites = Json.writes[InsertMetricGraphStructure]
  }

  def getRawStatsFor(listId: Int): Future[List[InsertMetric]] = {
    val queryRequest = new QueryRequest()
      .withTableName(TableName)
      .withKeyConditionExpression("list_id = :listId")
      .withExpressionAttributeValues(
        Map(":listId" -> new AttributeValue().withN(listId.toString)).asJava)

    dynamoDbClient.queryFuture(queryRequest).map{ queryResult =>
      queryResult.getItems.asScala.toList
        .map(_.asScala)
        .flatMap { attributeMap =>
          for {
            hits <- attributeMap.get("hits").map(_.getN)
{'fraction_non_alphanumeric': 0.10352220520673813, 'fraction_numerical': 0.009188361408882083, 'mean_word_length': 3.9186746987951806, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 17, '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': '7287284', 'n_tokens_mistral': 1002, 'n_tokens_neox': 980, 'n_words': 222}