| 1 | package edu.ucsb.cs156.courses.controllers; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | ||
| 5 | import edu.ucsb.cs156.courses.collections.ConvertedSectionCollection; | |
| 6 | import edu.ucsb.cs156.courses.documents.ConvertedSection; | |
| 7 | import edu.ucsb.cs156.courses.utilities.CourseUtilities; | |
| 8 | import io.swagger.annotations.ApiOperation; | |
| 9 | ||
| 10 | import org.slf4j.Logger; | |
| 11 | import org.slf4j.LoggerFactory; | |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | import org.springframework.http.ResponseEntity; | |
| 14 | import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 16 | import org.springframework.web.bind.annotation.RequestParam; | |
| 17 | import org.springframework.web.bind.annotation.RestController; | |
| 18 | ||
| 19 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 20 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 21 | ||
| 22 | @RestController | |
| 23 | @RequestMapping("/api/public/courseovertime") | |
| 24 | public class CourseOverTimeController { | |
| 25 | ||
| 26 | private final Logger logger = LoggerFactory.getLogger(CourseOverTimeController.class); | |
| 27 | ||
| 28 | private ObjectMapper mapper = new ObjectMapper(); | |
| 29 | ||
| 30 | @Autowired | |
| 31 | ConvertedSectionCollection convertedSectionCollection; | |
| 32 | ||
| 33 | @ApiOperation(value = "Get a list of courses over time") | |
| 34 | @GetMapping(value = "/search", produces = "application/json") | |
| 35 | public ResponseEntity<String> search( | |
| 36 | @RequestParam String startQtr, | |
| 37 | @RequestParam String endQtr, | |
| 38 | @RequestParam String subjectArea, | |
| 39 | @RequestParam String courseNumber | |
| 40 | ) throws JsonProcessingException { | |
| 41 | List<ConvertedSection> courseResults = convertedSectionCollection.findByQuarterRangeAndCourseId( | |
| 42 | startQtr, | |
| 43 | endQtr, | |
| 44 | CourseUtilities.makeFormattedCourseId(subjectArea, courseNumber) | |
| 45 | ); | |
| 46 | String body = mapper.writeValueAsString(courseResults); | |
| 47 |
1
1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeController::search → KILLED |
return ResponseEntity.ok().body(body); |
| 48 | } | |
| 49 | | |
| 50 | } | |
Mutations | ||
| 47 |
1.1 |