Skip to content

Commit

Permalink
Fix rebase-conflicts regarding ChangesetApi updates
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Rögner <benjamin.roegner@here.com>
  • Loading branch information
roegi committed Oct 18, 2024
1 parent 9d32c2a commit 94dc4a1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public ChangesetApi(RouterBuilder rb) {
*/
private void getChangesets(final RoutingContext context) {
try {
long startVersion = getLongQueryParam(context, START_VERSION);
long endVersion = getLongQueryParam(context, END_VERSION);
long startVersion = getLongQueryParam(context, START_VERSION, 0);
long endVersion = getLongQueryParam(context, END_VERSION, -1);

if (startVersion > endVersion)
throw new IllegalArgumentException("The parameter \"" + START_VERSION + "\" needs to be smaller than \"" + END_VERSION + "\".");
if (endVersion != -1 && startVersion > endVersion)
throw new IllegalArgumentException("The parameter \"" + START_VERSION + "\" needs to be smaller than or equal to \"" + END_VERSION + "\".");

IterateChangesetsEvent event = buildIterateChangesetsEvent(context, startVersion, endVersion);
//TODO: Add static caching to this endpoint, once the execution pipelines have been refactored.
Expand Down Expand Up @@ -155,8 +155,7 @@ private void getChangesetStatistics(final RoutingContext context) {
.onFailure(t -> sendErrorResponse(context, t));
}

private IterateChangesetsEvent buildIterateChangesetsEvent(final RoutingContext context, long startVersion, long endVersion)
throws HttpException {
private IterateChangesetsEvent buildIterateChangesetsEvent(final RoutingContext context, long startVersion, long endVersion) {
String pageToken = Query.getString(context, Query.PAGE_TOKEN, null);
long limit = Query.getLong(context, Query.LIMIT, IterateChangesets.DEFAULT_LIMIT);

Expand All @@ -168,15 +167,15 @@ private IterateChangesetsEvent buildIterateChangesetsEvent(final RoutingContext
.withLimit(limit);
}

private long getLongQueryParam(RoutingContext context, String paramName) {
private long getLongQueryParam(RoutingContext context, String paramName, long defaultValue) {
try {
long paramValue = Query.getLong(context, paramName);
if (paramValue < 0)
throw new IllegalArgumentException("The parameter \"" + paramName + "\" must be >= 0.");
return paramValue;
}
catch (NullPointerException e) {
throw new IllegalArgumentException("The parameter \"" + paramName + "\" is required.", e);
return defaultValue;
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("The parameter \"" + paramName + "\" is not a number.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public final class IterateChangesetsEvent extends SearchForFeaturesEvent<Iterate
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private long startVersion;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private long endVersion;
private long endVersion = -1;

private int versionsToKeep;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public SQLQuery buildIterateChangesets(IterateChangesetsEvent event){
.withNamedParameter("versionsToKeep", event.getVersionsToKeep())
.withNamedParameter("start", startVersion));

query.setQueryFragment("end_version", new SQLQuery("AND version <= #{end}")
.withNamedParameter("end", event.getEndVersion()));
query.setQueryFragment("end_version", event.getEndVersion() != -1 ? new SQLQuery("AND version <= #{end}")
.withNamedParameter("end", event.getEndVersion()) : new SQLQuery(""));

//Query one more feature as requested, to be able to determine if we need to include a nextPageToken
query.setQueryFragment("limit", new SQLQuery("LIMIT #{limit}").withNamedParameter("limit", limit + 1));
Expand Down

0 comments on commit 94dc4a1

Please sign in to comment.