Skip to content

Commit

Permalink
Added Counts Endpoints to Assessments
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Wiens committed Apr 30, 2024
1 parent b54f4a2 commit a3bde21
Showing 1 changed file with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ public ResponseEntity<List<ConnectionOfTravelAssessment>> findConnectionOfTravel
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/connection_of_travel/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countConnectionOfTravelAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = connectionOfTravelAssessmentRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = connectionOfTravelAssessmentRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Connection of Travel Assessments");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/lane_direction_of_travel", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
Expand All @@ -102,6 +123,28 @@ public ResponseEntity<List<LaneDirectionOfTravelAssessment>> findLaneDirectionOf

}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/lane_direction_of_travel/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countLaneDirectionOfTravelAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = laneDirectionOfTravelAssessmentRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = laneDirectionOfTravelAssessmentRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Lane Direction of Travel Assessments");
return ResponseEntity.ok(count);
}

}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_assessment", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
Expand All @@ -126,6 +169,28 @@ public ResponseEntity<List<StopLineStopAssessment>> findSignalStateAssessment(
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_assessment/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countSignalStateAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {

Query query = stopLineStopAssessmentRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = stopLineStopAssessmentRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Lane Direction of Travel Assessments");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_event_assessment", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
Expand All @@ -148,4 +213,25 @@ public ResponseEntity<List<StopLinePassageAssessment>> findSignalStateEventAsses
return ResponseEntity.ok(signalStateEventAssessmentRepo.find(query));
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_event_assessment/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countSignalStateEventAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = signalStateEventAssessmentRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = signalStateEventAssessmentRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Signal State Event Assessments");
return ResponseEntity.ok(count);
}
}
}

0 comments on commit a3bde21

Please sign in to comment.