Skip to content

Commit

Permalink
Merge pull request #73 from The-Huginn/issue-68
Browse files Browse the repository at this point in the history
Retrieve projects from lotteryConfig
  • Loading branch information
xstefank authored Mar 7, 2024
2 parents 4c2435b + b74980d commit ef553a8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/org/jboss/set/processing/CollectorProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ public class CollectorProducer {

public NewIssueCollector newIssueCollectorInstance(JiraEndpoint jiraEndpoint) {
LotteryConfig lotteryConfig = lotteryConfigProducer.getLotteryConfig();
Set<String> availableProjects = lotteryConfig.participants().stream()
.map(LotteryConfig.Participant::projects)
.map(projects -> projects.stream().map(LotteryConfig.Participant.Project::project).collect(Collectors.toSet()))
.flatMap(Collection::stream)
.collect(Collectors.toSet());
Set<String> availableProjects = getAvailableProjects(lotteryConfig);
SearchQuery searchQuery = SearchQuery.builder().projects(availableProjects).status(IssueStatus.NEW)
.assigneeEmpty()
.build();
Expand All @@ -36,10 +32,19 @@ public NewIssueCollector newIssueCollectorInstance(JiraEndpoint jiraEndpoint) {

public StaleIssueCollector newStaleIssueCollector(JiraEndpoint jiraEndpoint) {
LotteryConfig lotteryConfig = lotteryConfigProducer.getLotteryConfig();
SearchQuery searchQuery = SearchQuery.builder().projects("WFLY")
Set<String> availableProjects = getAvailableProjects(lotteryConfig);
SearchQuery searchQuery = SearchQuery.builder().projects(availableProjects)
.before(LocalDate.now().minusDays(lotteryConfig.delay().toDays())).assigneeNotEmpty()
.status(IssueStatus.CREATED, IssueStatus.ASSIGNED, IssueStatus.POST).build();
jiraEndpoint.setJql(JqlBuilder.build(searchQuery));
return new StaleIssueCollector(jiraEndpoint);
}

private Set<String> getAvailableProjects(LotteryConfig lotteryConfig) {
return lotteryConfig.participants().stream()
.map(LotteryConfig.Participant::projects)
.map(projects -> projects.stream().map(LotteryConfig.Participant.Project::project).collect(Collectors.toSet()))
.flatMap(Collection::stream)
.collect(Collectors.toSet());
}
}

0 comments on commit ef553a8

Please sign in to comment.