Skip to content

Commit 8dcb88a

Browse files
committed
exclude commits sometimes
1 parent 2a227ec commit 8dcb88a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/main/java/com/redhat/labs/lodestar/service/EngagementService.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.security.SecureRandom;
44
import java.util.ArrayList;
5+
import java.util.Collection;
56
import java.util.List;
67
import java.util.Map;
78
import java.util.Optional;
@@ -206,7 +207,7 @@ public List<Engagement> getAllEngagements() {
206207

207208
List<Project> projects = projectService.getProjectsByGroup(engagementRepositoryId, true);
208209

209-
return projects.parallelStream().map(project -> getEngagement(project, true))
210+
return projects.parallelStream().map(project -> getEngagement(project, true, true))
210211
.filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
211212

212213
}
@@ -217,7 +218,7 @@ public Engagement getEngagement(String namespaceOrId, boolean includeStatus) {
217218
Optional<Project> project = projectService.getProjectByIdOrPath(namespaceOrId);
218219

219220
if (project.isPresent()) {
220-
engagement = getEngagement(project.get(), includeStatus).orElse(null);
221+
engagement = getEngagement(project.get(), includeStatus, true).orElse(null);
221222
}
222223

223224
return engagement;
@@ -229,21 +230,23 @@ public Engagement getEngagement(String customerName, String engagementName, bool
229230
Optional<Project> project = getProject(customerName, engagementName);
230231

231232
if (project.isPresent()) {
232-
engagement = getEngagement(project.get(), includeStatus).orElse(null);
233+
engagement = getEngagement(project.get(), includeStatus, true).orElse(null);
233234
}
234235

235236
return engagement;
236237
}
237238

238-
public Optional<Engagement> getEngagement(Project project, boolean includeStatus) {
239+
public Optional<Engagement> getEngagement(Project project, boolean includeStatus, boolean includeCommits) {
239240
Engagement engagement = null;
240241

241242
Optional<File> engagementFile = fileService.getFileAllow404(project.getId(), ENGAGEMENT_FILE);
242243
if (engagementFile.isPresent()) {
243244
engagement = json.fromJson(engagementFile.get().getContent(), Engagement.class);
244245

245-
List<Commit> commits = projectService.getCommitLog(String.valueOf(engagement.getProjectId()));
246-
engagement.setCommits(commits);
246+
if (includeCommits) {
247+
List<Commit> commits = projectService.getCommitLog(String.valueOf(engagement.getProjectId()));
248+
engagement.setCommits(commits);
249+
}
247250
}
248251

249252
if (includeStatus && engagement != null) {
@@ -307,7 +310,7 @@ private CommitMultiple createCommitMultiple(List<File> filesToCommit, Integer pr
307310
.collect(Collectors.toList());
308311

309312
// merge the actions
310-
List<Action> actions = Stream.of(userManagementFiles, otherFiles).flatMap(x -> x.stream())
313+
List<Action> actions = Stream.of(userManagementFiles, otherFiles).flatMap(Collection::stream)
311314
.collect(Collectors.toList());
312315

313316
// use message if provided. otherwise, defaults
@@ -320,7 +323,7 @@ private CommitMultiple createCommitMultiple(List<File> filesToCommit, Integer pr
320323
}
321324

322325
private Action createAction(File file, boolean isNew) {
323-
FileAction action = isNew ? FileAction.CREATE : FileAction.UPDATE;
326+
FileAction action = isNew ? FileAction.create : FileAction.update;
324327

325328
return Action.builder().action(action).filePath(stripPrefix(file.getFilePath())).content(file.getContent())
326329
.encoding("base64").build();

0 commit comments

Comments
 (0)