<commit_before>package services.commands

import scala.concurrent.duration.DurationInt
import org.joda.time.DateTime
import controllers.api.Stats
import play.api.Logger
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.libs.Akka
import services.dao.StatsAppDao
import org.joda.time.format.DateTimeFormat

object SavedStatsAppPolling {
  
  val tempo = 10
  val log = Logger(SavedStatsAppPolling.getClass()).logger
  
  val scheduler = Akka.system.scheduler.schedule(0 second, tempo minute) {
    run()
  }
  
  def run() = {
    log.info("Run polling saved stats app")
    StatsAppDao.last().map( _.map { last:models.StatsApp =>
      log.info("is after : "+new DateTime(last.timestamp).plusHours(1).isBeforeNow())
      log.info(DateTimeFormat.forPattern("dd-MMMM-yyyy HH:mm").print(new DateTime(last.timestamp)))
      log.info(DateTimeFormat.forPattern("dd-MMMM-yyyy HH:mm").print(DateTime.now))
      if(new DateTime(last.timestamp).plusHours(1).isBeforeNow()) {
      log.info("Save stats app")
        Stats.createStatApp().flatMap { newStats =>
          StatsAppDao.add(newStats)
        }
      }
    })
  }
  
}<commit_msg>save stats if time is perfectly equal (akka scheduller precision <3)<commit_after>package services.commands

import scala.concurrent.duration.DurationInt
import org.joda.time.DateTime
import controllers.api.Stats
import play.api.Logger
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.libs.Akka
import services.dao.StatsAppDao
import org.joda.time.format.DateTimeFormat

object SavedStatsAppPolling {
  
  val tempo = 10
  val log = Logger(SavedStatsAppPolling.getClass()).logger
  
  val scheduler = Akka.system.scheduler.schedule(0 second, tempo minute) {
    run()
  }
  
  def run() = {
    log.info("Run polling saved stats app")
    StatsAppDao.last().map( _.map { last:models.StatsApp =>
      log.info("is after : "+new DateTime(last.timestamp).plusHours(1).isBeforeNow())
      log.info(DateTimeFormat.forPattern("dd-MMMM-yyyy HH:mm").print(new DateTime(last.timestamp)))
      log.info(DateTimeFormat.forPattern("dd-MMMM-yyyy HH:mm").print(DateTime.now))
      if(new DateTime(last.timestamp).plusHours(1).isEqualNow() || 
         new DateTime(last.timestamp).plusHours(1).isBeforeNow()) {
      log.info("Save stats app")
        Stats.createStatApp().flatMap { newStats =>
          StatsAppDao.add(newStats)
        }
      }
    })
  }
  
}
{'fraction_non_alphanumeric': 0.1275030649775235, 'fraction_numerical': 0.004903964037597058, 'mean_word_length': 3.828402366863905, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, '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': '2643920', 'n_tokens_mistral': 792, 'n_tokens_neox': 770, 'n_words': 132}