Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/java/previewcode/backend/DTO/OrderingGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ public OrderingGroup(String title, String description, List<HunkChecksum> hunks)
this.defaultGroup = false;
}

public OrderingGroup(String title, String description, List<HunkChecksum> hunks, boolean defaultGroup) {
public OrderingGroup(String title, String description, List<HunkChecksum> hunks, Boolean defaultGroup) {
this.hunkChecksums = hunks;
if(title == null){
title = "";
}

if(defaultGroup == null) {
this.defaultGroup = false;
} else {
this.defaultGroup = defaultGroup;
}
this.info = new TitleDescription(title, description);
this.defaultGroup = defaultGroup;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public Action<Unit> updateOrdering(PullRequestIdentifier pull, List<OrderingGrou
return insertPullIfNotExists(pull).then(pullID ->
fetchGroups(pullID).then(existingGroups ->
traverse(newGroups, createGroup(pullID))
.then(deriveDefaultGroup(existingGroups, newGroups)
.then(defaultGroup -> {
.then(deriveDefaultGroup(existingGroups, newGroups)
.then(defaultGroup -> traverse(existingGroups, g -> delete(g.id)).pure(defaultGroup))
.then(defaultGroup -> {
if (!defaultGroup.isEmpty()) return createGroup(pullID).apply(defaultGroup);
else return pure(unit);
}))
.then(traverse(existingGroups, g -> delete(g.id)))
)
).toUnit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.vavr.CheckedFunction1;
import io.vavr.collection.List;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -170,7 +171,7 @@ private static <T extends Throwable, R> R sneakyThrow(Throwable t) throws T {
* @return The response built from the action result.
*/
public Response evaluateToResponse(Action<?> action) {
return Response.ok().entity(unsafeEvaluate(action)).build();
return Response.ok().type(MediaType.APPLICATION_JSON_TYPE).entity(unsafeEvaluate(action)).build();
}

protected <A, X> Try<A> run(Action<A> action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected PullRequestID fetchPullRequest(FetchPull action) {

protected GroupID insertNewGroup(NewGroup newGroup) {
Boolean defaultGroup = newGroup.defaultGroup;
//Needed for the uniqueness constraint, as there should only be one default group
if(!newGroup.defaultGroup) {
defaultGroup = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public GitHubAuthInterpreter(
}

public static ActionCache.Builder configure(ActionCache.Builder b) {
return b.expire(GetUser.class).afterWrite(15, TimeUnit.MINUTES)
.expire(AuthenticateInstallation.class).afterWrite(1, TimeUnit.HOURS);
return b.expire(GetUser.class).afterWrite(15, TimeUnit.MINUTES);
//.expire(AuthenticateInstallation.class).afterWrite(1, TimeUnit.HOURS);
}

protected Unit authInstallation(AuthenticateInstallation action) throws IOException {
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/previewcode/backend/api/v2/EndPointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import previewcode.backend.APIModule;
import previewcode.backend.DTO.*;
import previewcode.backend.services.IGithubService;
import previewcode.backend.services.actiondsl.ActionDSL;
import previewcode.backend.services.actiondsl.Interpreter;
import previewcode.backend.test.helpers.ApiEndPointTest;
import previewcode.backend.database.PullRequestGroup;
Expand Down Expand Up @@ -131,6 +132,10 @@ public Action<Ordering> getOrdering(PullRequestIdentifier pull) {
return new NoOp<>();
}

@Override
public Action<Unit> mergeNewHunks(PullRequestIdentifier pull, List<HunkChecksum> newHunks) {
return new NoOp<>();
}


@Override
Expand Down