Skip to content

Commit

Permalink
Merge pull request #269 from seart-group/enhancement/log
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico authored Dec 31, 2023
2 parents 593bb6c + c6094d9 commit 9946598
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/main/java/ch/usi/si/seart/job/CleanUpProjectsJob.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.usi.si.seart.job;

import ch.usi.si.seart.config.properties.CleanUpProperties;
import ch.usi.si.seart.exception.ClientURLException;
import ch.usi.si.seart.exception.git.GitException;
import ch.usi.si.seart.git.GitConnector;
Expand All @@ -13,11 +14,15 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.scheduling.support.SimpleTriggerContext;
import org.springframework.transaction.annotation.Transactional;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

@Job
@Slf4j
Expand All @@ -26,6 +31,8 @@
@AllArgsConstructor(onConstructor_ = @Autowired)
public class CleanUpProjectsJob implements Runnable {

CleanUpProperties cleanUpProperties;

GitConnector gitConnector;
ClientURLConnector curlConnector;

Expand All @@ -35,7 +42,7 @@ public class CleanUpProjectsJob implements Runnable {
@Scheduled(cron = "${ghs.clean-up.cron}")
public void run() {
log.info(
"Started cleanup on {}/{} repositories",
"Started cleanup on {}/{} repositories",
gitRepoService.countCleanupCandidates(),
gitRepoService.count()
);
Expand All @@ -50,6 +57,10 @@ public void run() {
gitRepoService.pingById(id);
}
});
CronTrigger trigger = cleanUpProperties.getCron();
TriggerContext context = new SimpleTriggerContext();
Date date = trigger.nextExecutionTime(context);
log.info("Next cleanup scheduled for: {}", date);
}

/*
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/ch/usi/si/seart/job/CodeAnalysisJob.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.usi.si.seart.job;

import ch.usi.si.seart.analysis.CLOCConnector;
import ch.usi.si.seart.config.properties.AnalysisProperties;
import ch.usi.si.seart.exception.StaticCodeAnalysisException;
import ch.usi.si.seart.exception.git.GitException;
import ch.usi.si.seart.exception.git.RepositoryDisabledException;
Expand Down Expand Up @@ -35,6 +36,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -47,6 +51,8 @@ public class CodeAnalysisJob implements Runnable {

ApplicationContext applicationContext;

AnalysisProperties analysisProperties;

GitConnector gitConnector;
CLOCConnector clocConnector;

Expand All @@ -63,6 +69,9 @@ public void run() {
gitRepoService.count()
);
gitRepoService.streamAnalysisCandidates().forEach(this::analyze);
Duration delay = analysisProperties.getDelayBetweenRuns();
Instant instant = Instant.now().plus(delay);
log.info("Next analysis scheduled for: {}", Date.from(instant));
}

@Transactional(propagation = Propagation.REQUIRES_NEW)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ch/usi/si/seart/job/CrawlProjectsJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public void run() {
Range<Date> dateRange = Ranges.closed(lower, upper);
crawlRepositories(dateRange, language);
}
Duration delayBetweenRuns = crawlerProperties.getDelayBetweenRuns();
Instant nextRun = Instant.now().plus(delayBetweenRuns);
log.info("Next crawl scheduled for: {}", Date.from(nextRun));
Duration delay = crawlerProperties.getDelayBetweenRuns();
Instant instant = Instant.now().plus(delay);
log.info("Next crawl scheduled for: {}", Date.from(instant));
}

private void crawlRepositories(Range<Date> range, Language language) {
Expand Down

0 comments on commit 9946598

Please sign in to comment.