Skip to content

Commit

Permalink
Adding logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-ali-55 committed Sep 18, 2023
1 parent 653a1c5 commit 5283223
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RepositoryService(
.getAllRepositories(assignment)
.onSuccess {
logInfoMessages("vsm.repos.total", arrayOf(it.size), assignment)
logger.info { "Pulled ${it.size} repos. (run: ${assignment.runId})" }
saveAll(it, assignment, EventType.STATE)
logInfoStatus(
assignment = assignment,
Expand All @@ -42,16 +43,24 @@ class RepositoryService(
}

fun saveAll(repositories: List<Repository>, assignment: GitLabAssignment, eventType: EventType) {
kotlin.runCatching {
repositories
.takeIf { it.isNotEmpty() }
?.chunked(batchSize)
?.forEach {
repositoryProvider.saveAll(it, assignment, eventType)
repositories
.takeIf { it.isNotEmpty() }
?.chunked(batchSize)
?.forEach { batch ->
runCatching {
repositoryProvider.saveAll(batch, assignment, eventType)
}.onFailure {
logger.error {
"Error pushing ${batch.size} repos " +
"(run: ${assignment.runId}: ${it.message})"
}
}.onSuccess {
logger.info {
"Successfully pushed ${batch.size} repos " +
"(run: ${assignment.runId})"
}
}
}.onFailure {
logger.error(it) { "Failed save service" }
}
}
}

private fun handleExceptions(exception: Throwable, assignment: GitLabAssignment) {
Expand Down

0 comments on commit 5283223

Please sign in to comment.