Skip to content

Commit

Permalink
Revert "feat: ✨ Separated Qodana and Spoon mining (#729)"
Browse files Browse the repository at this point in the history
This reverts commit dda44b2.
  • Loading branch information
MartinWitt committed Jun 10, 2023
1 parent dda44b2 commit 79f41e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,54 +81,21 @@ private Project getKnownProject() {
}

void mine(@Observes StartupEvent event) {
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepoQodana()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepoSpoon()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepo()));
}

private void mineRandomRepoQodana() {
private void mineRandomRepo() {
try {
var project = queue.isEmpty() ? getRandomProject() : queue.poll();
var checkoutResult = checkoutProject(project);
if (checkoutResult instanceof ProjectResult.Error) {
logger.atWarning().log("Failed to checkout project %s", project);
mineRandomRepoQodana();
mineRandomRepo();
return;
}
if (checkoutResult instanceof ProjectResult.Success success) {
logger.atInfo().log("Successfully checked out project %s", success.project());
var qodanaResult = analyzeProject(success);

if (qodanaResult instanceof QodanaResult.Failure failure) {
logger.atWarning().log("Failed to analyze project %s", failure.message());
tryDeleteProject(success);
return;
}
if (qodanaResult instanceof QodanaResult.Success successResult) {
logger.atInfo().log("Successfully analyzed project %s", success.project());
saveQodanaResults(successResult);
addOrUpdateCommitHash(success);
}
}
} catch (Exception e) {
logger.atWarning().withCause(e).log("Failed to mine random repo");
} finally {
logger.atInfo().log("Queue size: %s", queue.size());
logger.atInfo().log("Mining next repo in 1 minute");
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepoQodana()));
}
}

private void mineRandomRepoSpoon() {
try {
var project = queue.isEmpty() ? getRandomProject() : queue.poll();
var checkoutResult = checkoutProject(project);
if (checkoutResult instanceof ProjectResult.Error) {
logger.atWarning().log("Failed to checkout project %s", project);
mineRandomRepoSpoon();
return;
}
if (checkoutResult instanceof ProjectResult.Success success) {
logger.atInfo().log("Successfully checked out project %s", success.project());
var spoonPatternAnalyzerResult =
spoonPatternAnalyzer.analyze(new AnalyzerRequest.WithProject(success.project()));

Expand All @@ -139,16 +106,28 @@ private void mineRandomRepoSpoon() {
}
if (spoonPatternAnalyzerResult instanceof SpoonPatternAnalyzerResult.Failure failure) {
logger.atWarning().log("Failed to analyze project with spoon %s", failure.message());
registry.counter("mining.spoon.error").increment();
tryDeleteProject(success);
}
if (qodanaResult instanceof QodanaResult.Failure failure) {
logger.atWarning().log("Failed to analyze project %s", failure.message());
registry.counter("mining.qodana.error").increment();
tryDeleteProject(success);
return;
}
if (qodanaResult instanceof QodanaResult.Success successResult) {
logger.atInfo().log("Successfully analyzed project %s", success.project());
saveQodanaResults(successResult);
addOrUpdateCommitHash(success);
}
}
} catch (Exception e) {
logger.atWarning().withCause(e).log("Failed to mine random repo");
registry.counter("mining.error").increment();
} finally {
logger.atInfo().log("Queue size: %s", queue.size());
logger.atInfo().log("Mining next repo in 1 minute");
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepoSpoon()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepo()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClientBuilder;
import jakarta.inject.Inject;
import java.util.regex.Pattern;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand Down

0 comments on commit 79f41e0

Please sign in to comment.