| 1 | package edu.ucsb.cs156.courses.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.courses.repositories.UCSBSubjectRepository; | |
| 4 | import edu.ucsb.cs156.courses.services.IsStaleService; | |
| 5 | import edu.ucsb.cs156.courses.services.UCSBCurriculumService; | |
| 6 | import edu.ucsb.cs156.courses.services.UpdateCoursesService; | |
| 7 | import edu.ucsb.cs156.jobs.services.JobRateLimit; | |
| 8 | import java.util.ArrayList; | |
| 9 | import java.util.List; | |
| 10 | import lombok.extern.slf4j.Slf4j; | |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | import org.springframework.stereotype.Service; | |
| 13 | ||
| 14 | @Service | |
| 15 | @Slf4j | |
| 16 | public class UpdateCourseDataJobFactory { | |
| 17 | ||
| 18 | @Autowired private UCSBCurriculumService curriculumService; | |
| 19 | ||
| 20 | @Autowired private UCSBSubjectRepository subjectRepository; | |
| 21 | ||
| 22 | @Autowired private IsStaleService isStaleService; | |
| 23 | ||
| 24 | @Autowired private JobRateLimit jobRateLimit; | |
| 25 | ||
| 26 | @Autowired private UpdateCoursesService updateCoursesService; | |
| 27 | ||
| 28 | public UpdateCourseDataJob createForSubjectAndQuarterAndIfStale( | |
| 29 | String subjectArea, String quarterYYYYQ, boolean ifStale) { | |
| 30 |
1
1. createForSubjectAndQuarterAndIfStale : replaced return value with null for edu/ucsb/cs156/courses/jobs/UpdateCourseDataJobFactory::createForSubjectAndQuarterAndIfStale → KILLED |
return new UpdateCourseDataJob( |
| 31 | quarterYYYYQ, | |
| 32 | quarterYYYYQ, | |
| 33 | List.of(subjectArea), | |
| 34 | curriculumService, | |
| 35 | isStaleService, | |
| 36 | ifStale, | |
| 37 | jobRateLimit, | |
| 38 | updateCoursesService); | |
| 39 | } | |
| 40 | ||
| 41 | public UpdateCourseDataJob createForSubjectAndQuarterRange( | |
| 42 | String subjectArea, String start_quarterYYYYQ, String end_quarterYYYYQ, boolean ifStale) { | |
| 43 |
1
1. createForSubjectAndQuarterRange : replaced return value with null for edu/ucsb/cs156/courses/jobs/UpdateCourseDataJobFactory::createForSubjectAndQuarterRange → KILLED |
return new UpdateCourseDataJob( |
| 44 | start_quarterYYYYQ, | |
| 45 | end_quarterYYYYQ, | |
| 46 | List.of(subjectArea), | |
| 47 | curriculumService, | |
| 48 | isStaleService, | |
| 49 | ifStale, | |
| 50 | jobRateLimit, | |
| 51 | updateCoursesService); | |
| 52 | } | |
| 53 | ||
| 54 | private List<String> getAllSubjectCodes() { | |
| 55 | var subjects = subjectRepository.findAll(); | |
| 56 | var subjectCodes = new ArrayList<String>(); | |
| 57 | for (var subject : subjects) { | |
| 58 | subjectCodes.add(subject.getSubjectCode()); | |
| 59 | } | |
| 60 |
1
1. getAllSubjectCodes : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/jobs/UpdateCourseDataJobFactory::getAllSubjectCodes → KILLED |
return subjectCodes; |
| 61 | } | |
| 62 | ||
| 63 | public UpdateCourseDataJob createForQuarter(String quarterYYYYQ, boolean ifStale) { | |
| 64 |
1
1. createForQuarter : replaced return value with null for edu/ucsb/cs156/courses/jobs/UpdateCourseDataJobFactory::createForQuarter → KILLED |
return new UpdateCourseDataJob( |
| 65 | quarterYYYYQ, | |
| 66 | quarterYYYYQ, | |
| 67 | getAllSubjectCodes(), | |
| 68 | curriculumService, | |
| 69 | isStaleService, | |
| 70 | ifStale, | |
| 71 | jobRateLimit, | |
| 72 | updateCoursesService); | |
| 73 | } | |
| 74 | ||
| 75 | public UpdateCourseDataJob createForQuarterRange( | |
| 76 | String start_quarterYYYYQ, String end_quarterYYYYQ, boolean ifStale) { | |
| 77 |
1
1. createForQuarterRange : replaced return value with null for edu/ucsb/cs156/courses/jobs/UpdateCourseDataJobFactory::createForQuarterRange → KILLED |
return new UpdateCourseDataJob( |
| 78 | start_quarterYYYYQ, | |
| 79 | end_quarterYYYYQ, | |
| 80 | getAllSubjectCodes(), | |
| 81 | curriculumService, | |
| 82 | isStaleService, | |
| 83 | ifStale, | |
| 84 | jobRateLimit, | |
| 85 | updateCoursesService); | |
| 86 | } | |
| 87 | } | |
Mutations | ||
| 30 |
1.1 |
|
| 43 |
1.1 |
|
| 60 |
1.1 |
|
| 64 |
1.1 |
|
| 77 |
1.1 |