| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.entities.Team; | |
| 5 | import edu.ucsb.cs156.frontiers.repositories.TeamRepository; | |
| 6 | import edu.ucsb.cs156.frontiers.services.GithubTeamService; | |
| 7 | import edu.ucsb.cs156.frontiers.services.GithubTeamService.GithubTeamInfo; | |
| 8 | import edu.ucsb.cs156.jobs.services.JobContext; | |
| 9 | import edu.ucsb.cs156.jobs.services.JobContextConsumer; | |
| 10 | import lombok.Builder; | |
| 11 | ||
| 12 | @Builder | |
| 13 | public class AddTeamToGithubJob implements JobContextConsumer { | |
| 14 | Course course; | |
| 15 | String teamName; | |
| 16 | TeamRepository teamRepository; | |
| 17 | GithubTeamService githubTeamService; | |
| 18 | ||
| 19 | @Override | |
| 20 | public String getScopeType() { | |
| 21 |
1
1. getScopeType : replaced return value with "" for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getScopeType → KILLED |
return "course"; |
| 22 | } | |
| 23 | ||
| 24 | @Override | |
| 25 | public Long getScopeId() { | |
| 26 |
1
1. getScopeId : replaced Long return value with 0L for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getScopeId → KILLED |
return course.getId(); |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public void accept(JobContext ctx) throws Exception { | |
| 31 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Starting add team to GitHub job for team: " + teamName); |
| 32 | ||
| 33 |
1
1. accept : negated conditional → KILLED |
if (teamName == null) { |
| 34 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("ERROR: Team has no name"); |
| 35 | return; | |
| 36 | } | |
| 37 | ||
| 38 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (course.getOrgName() == null || course.getInstallationId() == null) { |
| 39 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("ERROR: Course has no linked GitHub organization"); |
| 40 | return; | |
| 41 | } | |
| 42 | ||
| 43 | Team team = teamRepository.findByCourseIdAndName(course.getId(), teamName).orElse(null); | |
| 44 |
1
1. accept : negated conditional → KILLED |
if (team == null) { |
| 45 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log( |
| 46 | "ERROR: Team with name '" | |
| 47 | + teamName | |
| 48 | + "' not found for course " | |
| 49 | + course.getCourseName()); | |
| 50 | return; | |
| 51 | } | |
| 52 | ||
| 53 | try { | |
| 54 | GithubTeamInfo githubTeamInfo = githubTeamService.createTeamInfo(teamName, course); | |
| 55 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamId → KILLED |
team.setGithubTeamId(githubTeamInfo.id()); |
| 56 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamSlug → KILLED |
team.setGithubTeamSlug(githubTeamInfo.slug()); |
| 57 | teamRepository.save(team); | |
| 58 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log( |
| 59 | "Successfully added team '" | |
| 60 | + team.getName() | |
| 61 | + "' to GitHub with GitHub team ID: " | |
| 62 | + githubTeamInfo.id()); | |
| 63 | } catch (Exception e) { | |
| 64 | throw new IllegalStateException("Failed to add team to GitHub: " + e.getMessage(), e); | |
| 65 | } | |
| 66 | ||
| 67 |
1
1. accept : negated conditional → KILLED |
if (Boolean.TRUE.equals(team.getIsStaffTeam())) { |
| 68 | Integer orgId; | |
| 69 | try { | |
| 70 | orgId = githubTeamService.getOrgId(course.getOrgName(), course); | |
| 71 | } catch (Exception e) { | |
| 72 | throw new IllegalStateException( | |
| 73 | "Failed to get organization ID for org: " | |
| 74 | + course.getOrgName() | |
| 75 | + " - " | |
| 76 | + e.getMessage(), | |
| 77 | e); | |
| 78 | } | |
| 79 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/jobs/StaffTeamGithubSync::addStaffMembers → KILLED |
StaffTeamGithubSync.addStaffMembers(ctx, course, team, orgId, githubTeamService); |
| 80 | } | |
| 81 | ||
| 82 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Done"); |
| 83 | } | |
| 84 | } | |
Mutations | ||
| 21 |
1.1 |
|
| 26 |
1.1 |
|
| 31 |
1.1 |
|
| 33 |
1.1 |
|
| 34 |
1.1 |
|
| 38 |
1.1 2.2 |
|
| 39 |
1.1 |
|
| 44 |
1.1 |
|
| 45 |
1.1 |
|
| 55 |
1.1 |
|
| 56 |
1.1 |
|
| 58 |
1.1 |
|
| 67 |
1.1 |
|
| 79 |
1.1 |
|
| 82 |
1.1 |