Skip to content

Commit

Permalink
Add missing annotation to config fields
Browse files Browse the repository at this point in the history
  • Loading branch information
grdryn committed Apr 16, 2023
1 parent a23ecf8 commit 8631a7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/bf2/arch/bot/ArchBotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public class ArchBotConfig {
/**
* Github login name of the bot itself.
*/
@JsonDeserialize
String botUserLogin;

/**
* The time, in minutes, to wait between checking for stalled discussions.
*/
@JsonDeserialize
long stalledDiscussionPollTimeMins;

/**
Expand All @@ -31,7 +33,8 @@ public class ArchBotConfig {
/**
* The URL at which the site is published.
*/
String publishedUrl = "https://architecture.appservices.tech";
@JsonDeserialize
String publishedUrl;

@Override
public String toString() {
Expand Down
35 changes: 17 additions & 18 deletions src/main/java/org/bf2/arch/bot/StalledDiscussionFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void init(GitHubService service, GitHubConfigFileProvider configFileProvider) th
Optional<ArchBotConfig> oconfig = configFileProvider.fetchConfigFile(client.getRepository(repositoryPath),
Util.CONFIG_REPO_PATH, ConfigFile.Source.DEFAULT, ArchBotConfig.class);
config = oconfig.orElseThrow();
LOG.info("CONFIGG: {}", config);
} else {
throw new RuntimeException("installation id is requied");
}
Expand Down Expand Up @@ -122,7 +121,7 @@ public void checkForStalledDiscussions() throws IOException {
.list();
LOG.info("Top-level query found {} PRs", results.getTotalCount());
for (GHIssue issue : results) {
try {
try {
GHPullRequest pullRequest = Util.findPullRequest(issue);
if (pullRequest == null) {
LOG.info("Issue#{} is not a PR, ignoring", issue.getNumber());
Expand All @@ -137,14 +136,14 @@ public void checkForStalledDiscussions() throws IOException {
Date lastCommentDate;
LOG.info("COMMENTS COUNT: {}", pullRequest.listReviewComments().toList().size());
var mostRecent = pullRequest.listReviewComments().toList().stream()
.filter(pr -> {
try {
return !Util.isThisBot(config, pr.getUser());
} catch (IOException e) {
return true;
}
})
.map(comment -> {
.filter(pr -> {
try {
return !Util.isThisBot(config, pr.getUser());
} catch (IOException e) {
return true;
}
})
.map(comment -> {
try {
LOG.info("Comment: {}", comment.getBody());
LOG.info("User: {}", comment.getUser().getLogin());
Expand All @@ -155,16 +154,16 @@ public void checkForStalledDiscussions() throws IOException {
}).max(Date::compareTo);

lastCommentDate = mostRecent.orElseGet(() -> {
try {
return pullRequest.getUpdatedAt();
} catch (IOException e) {
try {
return pullRequest.getCreatedAt();
} catch (IOException ex) {
return new Date(0);
return pullRequest.getUpdatedAt();
} catch (IOException e) {
try {
return pullRequest.getCreatedAt();
} catch (IOException ex) {
return new Date(0);
}
}
}
});
});
LOG.info("PR#{}: Last comment time {}", pullRequest.getNumber(), lastCommentDate);

if (lastCommentDate.getTime() < thresh) {
Expand Down

0 comments on commit 8631a7d

Please sign in to comment.