| 1 | package edu.ucsb.cs156.happiercows.jobs; | |
| 2 | ||
| 3 | import java.util.Optional; | |
| 4 | ||
| 5 | import edu.ucsb.cs156.happiercows.entities.Commons; | |
| 6 | import edu.ucsb.cs156.happiercows.entities.Report; | |
| 7 | import edu.ucsb.cs156.happiercows.entities.User; | |
| 8 | import edu.ucsb.cs156.happiercows.entities.UserCommons; | |
| 9 | import edu.ucsb.cs156.happiercows.repositories.CommonsRepository; | |
| 10 | import edu.ucsb.cs156.happiercows.repositories.ReportLineRepository; | |
| 11 | import edu.ucsb.cs156.happiercows.repositories.ReportRepository; | |
| 12 | import edu.ucsb.cs156.happiercows.repositories.UserCommonsRepository; | |
| 13 | import edu.ucsb.cs156.happiercows.repositories.UserRepository; | |
| 14 | import edu.ucsb.cs156.happiercows.services.jobs.JobContext; | |
| 15 | import edu.ucsb.cs156.happiercows.services.jobs.JobContextConsumer; | |
| 16 | ||
| 17 | import edu.ucsb.cs156.happiercows.services.ReportService; | |
| 18 | ||
| 19 | import lombok.AllArgsConstructor; | |
| 20 | import lombok.Builder; | |
| 21 | import lombok.Getter; | |
| 22 | ||
| 23 | @Builder | |
| 24 | @AllArgsConstructor | |
| 25 | public class InstructorReportJob implements JobContextConsumer { | |
| 26 | ||
| 27 | @Getter | |
| 28 | private ReportService reportService; | |
| 29 | ||
| 30 | @Getter | |
| 31 | private CommonsRepository commonsRepository; | |
| 32 | ||
| 33 | @Override | |
| 34 | public void accept(JobContext ctx) throws Exception { | |
| 35 |
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED |
ctx.log("Starting instructor report..."); |
| 36 | Iterable<Commons> allCommons = commonsRepository.findAll(); | |
| 37 | ||
| 38 | for (Commons commons : allCommons) { | |
| 39 |
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED |
ctx.log(String.format("Starting Commons id=%d (%s)...", commons.getId(), commons.getName())); |
| 40 | Report report = reportService.createReport(commons.getId()); | |
| 41 |
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED |
ctx.log(String.format("Report %d for commons id=%d (%s) finished.", report.getId(), commons.getId(), |
| 42 | commons.getName())); | |
| 43 | } | |
| 44 |
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED |
ctx.log("Instructor report done!"); |
| 45 | } | |
| 46 | } | |
Mutations | ||
| 35 |
1.1 |
|
| 39 |
1.1 |
|
| 41 |
1.1 |
|
| 44 |
1.1 |