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