99import de .tum .cit .aet .repositoryProcessing .dto .ParticipationDTO ;
1010import de .tum .cit .aet .repositoryProcessing .dto .TeamDTO ;
1111import de .tum .cit .aet .repositoryProcessing .dto .TeamRepositoryDTO ;
12+ import de .tum .cit .aet .repositoryProcessing .repository .StudentRepository ;
13+ import de .tum .cit .aet .repositoryProcessing .repository .TeamParticipationRepository ;
1214import de .tum .cit .aet .repositoryProcessing .repository .TeamRepositoryRepository ;
15+ import de .tum .cit .aet .repositoryProcessing .repository .TutorRepository ;
1316import de .tum .cit .aet .repositoryProcessing .service .RepositoryFetchingService ;
1417import lombok .extern .slf4j .Slf4j ;
1518import org .springframework .beans .factory .annotation .Autowired ;
@@ -24,11 +27,17 @@ public class RequestService {
2427
2528 private final RepositoryFetchingService repositoryFetchingService ;
2629 private final TeamRepositoryRepository teamRepositoryRepository ;
30+ private final TeamParticipationRepository teamParticipationRepository ;
31+ private final TutorRepository tutorRepository ;
32+ private final StudentRepository studentRepository ;
2733
2834 @ Autowired
29- public RequestService (RepositoryFetchingService repositoryFetchingService , TeamRepositoryRepository teamRepositoryRepository ) {
35+ public RequestService (RepositoryFetchingService repositoryFetchingService , TeamRepositoryRepository teamRepositoryRepository , TeamParticipationRepository teamParticipationRepository , TutorRepository tutorRepository , StudentRepository studentRepository ) {
3036 this .repositoryFetchingService = repositoryFetchingService ;
3137 this .teamRepositoryRepository = teamRepositoryRepository ;
38+ this .teamParticipationRepository = teamParticipationRepository ;
39+ this .tutorRepository = tutorRepository ;
40+ this .studentRepository = studentRepository ;
3241 }
3342
3443 /**
@@ -55,15 +64,22 @@ public void saveResults(List<TeamRepositoryDTO> repositories)
5564 for (TeamRepositoryDTO repo : repositories ) {
5665 ParticipantDTO tut = repo .participation ().team ().owner ();
5766 Tutor tutor = new Tutor (tut .id (), tut .login (), tut .name ());
67+ tutorRepository .save (tutor );
68+
5869 ParticipationDTO participation = repo .participation ();
5970 TeamDTO team = participation .team ();
6071 TeamParticipation teamParticipation = new TeamParticipation (participation .id (), team .id (), tutor , team .name (), team .shortName (), participation .repositoryUri (), participation .submissionCount ());
72+ teamParticipationRepository .save (teamParticipation );
73+
6174 List <Student > students = new ArrayList <>();
6275 for (ParticipantDTO student : repo .participation ().team ().students ()) {
6376 students .add (new Student (student .id (), student .login (), student .name (), teamParticipation ));
6477 }
78+ studentRepository .saveAll (students );
79+
6580 TeamRepository teamRepo = new TeamRepository (teamParticipation , repo .localPath (), repo .isCloned (), repo .error ());
6681 teamRepositoryRepository .save (teamRepo );
82+
6783 log .info ("Processed repository for team: {}" , team .name ());
6884 }
6985 }
0 commit comments