Class StatisticsController
java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.StatisticsController
@RequestMapping("/api/statistics")
@RestController
public class StatisticsController
extends ApiController
REST controller that exposes aggregated review statistics. These endpoints power the "Review
Statistics" pages of the frontend.
Only reviews with moderation status ModerationStatus.APPROVED (or reviews that have no
comments and were therefore auto-approved) are considered when computing the statistics, so that
unmoderated user content does not influence what we publish.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBest items endpoint, supports a time period filter and a maximum result count.commonsAverages(String period) Average review score for each dining commons.Average review score for each dining commons grouped by month (used to draw a graph).commonsMealAverages(String code) Average review score for each meal slot at the supplied dining commons.worstItems(String period, int limit) Worst items endpoint, supports a time period filter and a maximum result count.Methods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException, handleUnsupportedOperation
-
Field Details
-
PERIOD_ALL
Supported time-period filters for the best/worst items endpoints.- See Also:
-
PERIOD_6M
- See Also:
-
PERIOD_1M
- See Also:
-
PERIOD_1W
- See Also:
-
-
Constructor Details
-
StatisticsController
public StatisticsController()
-
-
Method Details
-
handleValidationExceptions
@ExceptionHandler(IllegalArgumentException.class) public org.springframework.http.ResponseEntity<Map<String,String>> handleValidationExceptions(IllegalArgumentException ex) -
bestItems
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/items/best") public List<ItemStatistic> bestItems(@RequestParam(name="period",defaultValue="ALL") String period, @RequestParam(name="limit",defaultValue="5") int limit) Best items endpoint, supports a time period filter and a maximum result count. -
worstItems
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/items/worst") public List<ItemStatistic> worstItems(@RequestParam(name="period",defaultValue="ALL") String period, @RequestParam(name="limit",defaultValue="5") int limit) Worst items endpoint, supports a time period filter and a maximum result count. -
commonsAverages
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/commons/averages") public List<CommonsAverage> commonsAverages(@RequestParam(name="period",defaultValue="ALL") String period) Average review score for each dining commons. -
commonsAveragesOverTime
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/commons/averages/overtime") public List<CommonsAverageOverTime> commonsAveragesOverTime()Average review score for each dining commons grouped by month (used to draw a graph). -
commonsMealAverages
@PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/commons/{code}/meals/averages") public List<MealAverage> commonsMealAverages(@PathVariable("code") String code) Average review score for each meal slot at the supplied dining commons.
-