Skip to content

Commit

Permalink
Simplifying API
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico committed Aug 3, 2023
1 parent 5adceed commit 6a4e7a4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void gatherCodeMetricsFor(@NotNull GitRepo gitRepo) {
log.warn("No metrics were computed for: {}", name);
gitRepo.setMetrics(metrics);
gitRepo.setLastAnalyzed();
gitRepoService.updateRepo(gitRepo);
gitRepoService.createOrUpdate(gitRepo);
} catch (StaticCodeAnalysisException ex) {
log.error("Static code analysis failed for: {}", name);
log.debug("", ex);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/usi/si/seart/job/CleanUpProjectsJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void run() {
gitRepoService.deleteRepoById(id);
} else {
gitRepo.setLastPinged();
gitRepoService.updateRepo(gitRepo);
gitRepoService.createOrUpdate(gitRepo);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/usi/si/seart/job/CrawlProjectsJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private void saveRetrievedRepo(JsonObject result, String language, int lowerInde
Language mainLanguage = languageService.getOrCreate(language);
gitRepo.setMainLanguage(mainLanguage);

gitRepo = gitRepoService.updateRepo(gitRepo);
gitRepo = gitRepoService.createOrUpdate(gitRepo);

Set<Label> labels = retrieveRepoLabels(gitRepo);
if (!labels.isEmpty())
Expand All @@ -299,7 +299,7 @@ private void saveRetrievedRepo(JsonObject result, String language, int lowerInde
log.debug("\tAdding: {} topics.", topics.size());
gitRepo.setTopics(topics);

gitRepoService.updateRepo(gitRepo);
gitRepoService.createOrUpdate(gitRepo);
} catch (NonTransientDataAccessException ex) {
throw ex;
} catch (Exception ex) {
Expand Down
20 changes: 2 additions & 18 deletions src/main/java/usi/si/seart/service/GitRepoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ public interface GitRepoService {
backoff = @Backoff(delay = 250, multiplier = 2),
maxAttempts = 5
)
GitRepo createOrUpdateRepo(GitRepo repo);
@Retryable(
value = TransientDataAccessException.class,
backoff = @Backoff(delay = 250, multiplier = 2),
maxAttempts = 5
)
GitRepo updateRepo(GitRepo repo);
GitRepo createOrUpdate(GitRepo repo);
Optional<GitRepo> getNextDeletionCandidate();
Page<GitRepo> findDynamically(GitRepoSearch parameters, Pageable pageable);
Stream<GitRepo> streamDynamically(GitRepoSearch parameters);
Expand Down Expand Up @@ -93,17 +87,7 @@ public GitRepo getByName(String name) {
}

@Override
public GitRepo createOrUpdateRepo(GitRepo repo) {
String name = repo.getName();
Long id = gitRepoRepository.findGitRepoByNameIgnoreCase(name)
.map(GitRepo::getId)
.orElse(null);
repo.setId(id);
return gitRepoRepository.save(repo);
}

@Override
public GitRepo updateRepo(GitRepo repo) {
public GitRepo createOrUpdate(GitRepo repo) {
return gitRepoRepository.save(repo);
}

Expand Down

0 comments on commit 6a4e7a4

Please sign in to comment.