From a7b20821b077c9f6e0c8873774993b33e247aeb1 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:06:56 -0500 Subject: [PATCH] refactor(MonitoredTripController): Remove unused endpoint, update swagger. --- .../api/MonitoredTripController.java | 30 ------------------- .../latest-spark-swagger-output.yaml | 29 ------------------ 2 files changed, 59 deletions(-) diff --git a/src/main/java/org/opentripplanner/middleware/controllers/api/MonitoredTripController.java b/src/main/java/org/opentripplanner/middleware/controllers/api/MonitoredTripController.java index 113217b5a..49b854425 100644 --- a/src/main/java/org/opentripplanner/middleware/controllers/api/MonitoredTripController.java +++ b/src/main/java/org/opentripplanner/middleware/controllers/api/MonitoredTripController.java @@ -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; @@ -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) @@ -79,21 +64,6 @@ protected Bson getEntityFilter(OtpUser user) { ); } - private ResponseList 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. diff --git a/src/main/resources/latest-spark-swagger-output.yaml b/src/main/resources/latest-spark-swagger-output.yaml index d8b5480a6..60ecf59fd 100644 --- a/src/main/resources/latest-spark-swagger-output.yaml +++ b/src/main/resources/latest-spark-swagger-output.yaml @@ -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: