<commit_before>package com.softwaremill.codebrag.service.updater

import akka.actor._
import com.typesafe.scalalogging.slf4j.Logging
import com.softwaremill.codebrag.service.commits.CommitImportService
import RepoUpdateActor._
import com.softwaremill.codebrag.repository.Repository

class RepoUpdateActor(importService: CommitImportService, repository: Repository) extends Actor with Logging {

  def receive = {
    case Update(scheduleNext) => {
      try {
        importService.importRepoCommits(repository)
        importService.cleanupStaleBranches()
      } finally {
        if (scheduleNext) {
          import context.dispatcher
          logger.debug("Scheduling next update delay to " + NextUpdatesInterval.toString)
          context.system.scheduler.scheduleOnce(NextUpdatesInterval, self, Update(scheduleNext = true))
        }
      }
    }
  }
}

object RepoUpdateActor {

  import scala.concurrent.duration._

  val InitialDelay = 3.seconds
  val NextUpdatesInterval = 45.seconds

  case class Update(scheduleNext: Boolean)
}<commit_msg>Clean stale branches for repo specified after loading repo update<commit_after>package com.softwaremill.codebrag.service.updater

import akka.actor._
import com.typesafe.scalalogging.slf4j.Logging
import com.softwaremill.codebrag.service.commits.CommitImportService
import RepoUpdateActor._
import com.softwaremill.codebrag.repository.Repository

class RepoUpdateActor(importService: CommitImportService, repository: Repository) extends Actor with Logging {

  def receive = {
    case Update(scheduleNext) => {    // TODO: get rid of this scheduleNext
      try {
        importService.importRepoCommits(repository)
        importService.cleanupStaleBranches(repository)
      } finally {
        if (scheduleNext) {
          import context.dispatcher
          logger.debug(s"Scheduling next update of ${repository.repoName} in ${NextUpdatesInterval.toString}")
          context.system.scheduler.scheduleOnce(NextUpdatesInterval, self, Update(scheduleNext = true))
        }
      }
    }
  }
}

object RepoUpdateActor {

  import scala.concurrent.duration._

  val InitialDelay = 3.seconds
  val NextUpdatesInterval = 45.seconds

  case class Update(scheduleNext: Boolean)
}
{'fraction_non_alphanumeric': 0.0783348254252462, 'fraction_numerical': 0.0035810205908683975, 'mean_word_length': 3.901315789473684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '539088', 'n_tokens_mistral': 636, 'n_tokens_neox': 614, 'n_words': 130}