Skip to content

Commit

Permalink
refactor(MonitoredTripController): Remove unused endpoint, update swa…
Browse files Browse the repository at this point in the history
…gger.
  • Loading branch information
binh-dam-ibigroup committed Nov 21, 2024
1 parent f8cc20a commit a7b2082
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
import com.mongodb.client.model.Filters;
import org.bson.conversions.Bson;
import org.eclipse.jetty.http.HttpStatus;
import org.opentripplanner.middleware.auth.Auth0Connection;
import org.opentripplanner.middleware.auth.RequestingUser;
import org.opentripplanner.middleware.controllers.response.ResponseList;
import org.opentripplanner.middleware.models.ItineraryExistence;
import org.opentripplanner.middleware.models.MonitoredTrip;
import org.opentripplanner.middleware.models.OtpUser;
import org.opentripplanner.middleware.persistence.Persistence;
import org.opentripplanner.middleware.tripmonitor.jobs.CheckMonitoredTrip;
import org.opentripplanner.middleware.tripmonitor.jobs.MonitoredTripLocks;
import org.opentripplanner.middleware.utils.HttpUtils;
import org.opentripplanner.middleware.utils.InvalidItineraryReason;
import org.opentripplanner.middleware.utils.JsonUtils;
import org.opentripplanner.middleware.utils.SwaggerUtils;
Expand Down Expand Up @@ -48,17 +44,6 @@ public MonitoredTripController(String apiPrefix) {
protected void buildEndpoint(ApiEndpoint baseEndpoint) {
// Add the api key route BEFORE the regular CRUD methods
ApiEndpoint modifiedEndpoint = baseEndpoint
// Get all trips, including shared trips created by others.
.get(path(ROOT_ROUTE + "/gettrips")
.withDescription(
"Gets a paginated list of trips created by the current user and shared trips created by others where the current user is the primary traveler or a companion or an observer."
)
.withQueryParam(LIMIT)
.withQueryParam(OFFSET)
.withProduces(HttpUtils.JSON_ONLY)
.withResponseType(ResponseList.class),
this::getTrips, JsonUtils::toJson
)
.post(path("/checkitinerary")
.withDescription("Returns the itinerary existence check results for a monitored trip.")
.withRequestType(MonitoredTrip.class)
Expand All @@ -79,21 +64,6 @@ protected Bson getEntityFilter(OtpUser user) {
);
}

private ResponseList<MonitoredTrip> getTrips(Request req, Response res) {
int limit = HttpUtils.getQueryParamFromRequest(req, LIMIT_PARAM, 0, DEFAULT_LIMIT, 100);
int offset = HttpUtils.getQueryParamFromRequest(req, OFFSET_PARAM, 0, DEFAULT_OFFSET);
RequestingUser requestingUser = Auth0Connection.getUserFromRequest(req);

String userId = requestingUser.otpUser.id;
Bson finalFilter = Filters.or(
Filters.eq(USER_ID_PARAM, userId),
Filters.eq("primary.userId", userId),
Filters.eq("companion.email", requestingUser.otpUser.email),
Filters.eq("observers.email", requestingUser.otpUser.email)
);
return persistence.getResponseList(finalFilter, offset, limit);
}

/**
* Before creating a {@link MonitoredTrip}, check that the itinerary associated with the trip exists on the selected
* days of the week. Update the itinerary if everything looks OK, otherwise halt the request.
Expand Down
29 changes: 0 additions & 29 deletions src/main/resources/latest-spark-swagger-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,35 +1031,6 @@ paths:
description: "An error occurred while performing the request. Contact an\
\ API administrator for more information."
examples: {}
/api/secure/monitoredtrip/gettrips:
get:
tags:
- "api/secure/monitoredtrip"
description: "Gets a paginated list of trips created by the current user and\
\ shared trips created by others where the current user is the primary traveler\
\ or a companion or an observer."
produces:
- "application/json"
parameters:
- name: "limit"
in: "query"
description: "If specified, the maximum number of items to return."
required: false
type: "string"
default: "10"
- name: "offset"
in: "query"
description: "If specified, the number of records to skip/offset."
required: false
type: "string"
default: "0"
responses:
"200":
description: "successful operation"
responseSchema:
$ref: "#/definitions/ResponseList"
schema:
$ref: "#/definitions/ResponseList"
/api/secure/monitoredtrip/checkitinerary:
post:
tags:
Expand Down

0 comments on commit a7b2082

Please sign in to comment.