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

import com.softwaremill.codebrag.common.EventBus
import com.typesafe.scalalogging.slf4j.Logging
import com.softwaremill.codebrag.domain.{MultibranchLoadCommitsResult, PartialCommitInfo, NewCommitsLoadedEvent, RepositoryStatus}
import com.softwaremill.codebrag.dao.repositorystatus.RepositoryStatusDAO
import com.softwaremill.codebrag.repository.Repository
import com.softwaremill.codebrag.dao.branchsnapshot.BranchStateDAO
import com.softwaremill.codebrag.cache.RepositoriesCache
import com.softwaremill.codebrag.service.config.CommitCacheConfig

class CommitImportService(repoStatusDao: RepositoryStatusDAO, branchStateDao: BranchStateDAO, repositoriesCache: RepositoriesCache, config: CommitCacheConfig, eventBus: EventBus) extends Logging {

  def importRepoCommits(repository: Repository) {
    try {
      repository.pullChanges()
    } catch {
      // TODO: refactor a bit and  add info to user that remote repository is unavailable
      case e: Exception => logger.error("Cannot pull changes from upstream", e)
    }
    try {
      val loaded = repository.loadCommitsSince(branchStateDao.loadBranchesStateAsMap(repository.repoName), config.maxCommitsCachedPerBranch)
      if (loaded.commits.nonEmpty) {
        publishNewCommitsLoaded(repository, loaded)
      }<commit_msg>Adds missing implicit parameter Refs #48<commit_after>package com.softwaremill.codebrag.service.commits

import com.softwaremill.codebrag.common.{Clock, EventBus}
import com.typesafe.scalalogging.slf4j.Logging
import com.softwaremill.codebrag.domain.{MultibranchLoadCommitsResult, PartialCommitInfo, NewCommitsLoadedEvent, RepositoryStatus}
import com.softwaremill.codebrag.dao.repositorystatus.RepositoryStatusDAO
import com.softwaremill.codebrag.repository.Repository
import com.softwaremill.codebrag.dao.branchsnapshot.BranchStateDAO
import com.softwaremill.codebrag.cache.RepositoriesCache
import com.softwaremill.codebrag.service.config.CommitCacheConfig

class CommitImportService(
  repoStatusDao: RepositoryStatusDAO,
  branchStateDao: BranchStateDAO,
  repositoriesCache: RepositoriesCache,
  config: CommitCacheConfig,
  eventBus: EventBus
)(implicit clock: Clock) extends Logging {

  def importRepoCommits(repository: Repository) {
    try {
      repository.pullChanges()
    } catch {
      // TODO: refactor a bit and  add info to user that remote repository is unavailable
      case e: Exception => logger.error("Cannot pull changes from upstream", e)
    }
    try {
      val loaded = repository.loadCommitsSince(branchStateDao.loadBranchesStateAsMap(repository.repoName), config.maxCommitsCachedPerBranch)
      if (loaded.commits.nonEmpty) {
        publishNewCommitsLoaded(repository, loaded)
      }
{'fraction_non_alphanumeric': 0.07609087630724846, 'fraction_numerical': 0.00144248106743599, 'mean_word_length': 5.652278177458034, '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': '1094966', 'n_tokens_mistral': 808, 'n_tokens_neox': 798, 'n_words': 154}