| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.entities.RosterStudent; | |
| 5 | import edu.ucsb.cs156.frontiers.enums.OrgStatus; | |
| 6 | import edu.ucsb.cs156.frontiers.models.OrgMember; | |
| 7 | import edu.ucsb.cs156.frontiers.repositories.RosterStudentRepository; | |
| 8 | import edu.ucsb.cs156.frontiers.services.OrganizationMemberService; | |
| 9 | import edu.ucsb.cs156.jobs.services.JobContext; | |
| 10 | import edu.ucsb.cs156.jobs.services.JobContextConsumer; | |
| 11 | import java.util.Optional; | |
| 12 | import lombok.Builder; | |
| 13 | ||
| 14 | @Builder | |
| 15 | public class UpdateOrgMembershipJob implements JobContextConsumer { | |
| 16 | Course course; | |
| 17 | OrganizationMemberService organizationMemberService; | |
| 18 | RosterStudentRepository rosterStudentRepository; | |
| 19 | ||
| 20 | @Override | |
| 21 | public String getScopeType() { | |
| 22 |
1
1. getScopeType : replaced return value with "" for edu/ucsb/cs156/frontiers/jobs/UpdateOrgMembershipJob::getScopeType → KILLED |
return "course"; |
| 23 | } | |
| 24 | ||
| 25 | @Override | |
| 26 | public Long getScopeId() { | |
| 27 |
1
1. getScopeId : replaced Long return value with 0L for edu/ucsb/cs156/frontiers/jobs/UpdateOrgMembershipJob::getScopeId → KILLED |
return course.getId(); |
| 28 | } | |
| 29 | ||
| 30 | @Override | |
| 31 | public void accept(JobContext ctx) throws Exception { | |
| 32 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Processing..."); |
| 33 | Iterable<OrgMember> members = organizationMemberService.getOrganizationMembers(course); | |
| 34 | for (OrgMember member : members) { | |
| 35 | // This loop never calls ctx.log() -- only the opening "Processing..." and closing "Done" | |
| 36 | // lines do. checkCancellation() gives it its own checkpoint independent of member count. | |
| 37 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::checkCancellation → KILLED |
ctx.checkCancellation(); |
| 38 | Optional<RosterStudent> student = | |
| 39 | rosterStudentRepository.findByCourseAndGithubId(course, member.getGithubId()); | |
| 40 |
1
1. accept : negated conditional → KILLED |
if (student.isPresent()) { |
| 41 | RosterStudent foundStudent = student.get(); | |
| 42 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/RosterStudent::setOrgStatus → KILLED |
foundStudent.setOrgStatus(OrgStatus.MEMBER); |
| 43 | rosterStudentRepository.save(foundStudent); | |
| 44 | } | |
| 45 | } | |
| 46 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Done"); |
| 47 | } | |
| 48 | } | |
Mutations | ||
| 22 |
1.1 |
|
| 27 |
1.1 |
|
| 32 |
1.1 |
|
| 37 |
1.1 |
|
| 40 |
1.1 |
|
| 42 |
1.1 |
|
| 46 |
1.1 |