Skip to content

Commit

Permalink
Make updateProgressForCourses ignore module not present
Browse files Browse the repository at this point in the history
  • Loading branch information
ole-ve committed Oct 22, 2024
1 parent 23f7a0d commit 763afc1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public void updateProgressByLearningObjectSync(LearningObject learningObject, Se
* @param activeCourses the active courses
*/
public void updateProgressForCourses(List<Course> activeCourses) {
if (!isActive()) {
return;
}

CompetencyProgressService competencyProgressService = getOrThrow(this.competencyProgressService);
CompetencyRepository competencyRepository = getOrThrow(this.competencyRepository);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public AbstractApi(Environment environment, String profileName) {
this.profileName = profileName;
}

public boolean isActive(String profileName) {
public boolean isActive() {
return isActive(profileName);
}

// This method will be removed once we switch to using the profileName
private boolean isActive(String profileName) {
return environment.acceptsProfiles(Profiles.of(profileName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi;
import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.exception.ModuleNotPresentException;
import de.tum.cit.aet.artemis.core.repository.CourseRepository;

public class MigrationEntry20240614_140000 extends MigrationEntry {
Expand All @@ -30,6 +31,9 @@ public void execute() {

log.info("Updating competency progress for {} active courses", activeCourses.size());

if (!competencyProgressApi.isActive()) {
throw new ModuleNotPresentException("CompetencyProgressApi is not active");
}
competencyProgressApi.updateProgressForCourses(activeCourses);
}

Expand Down

0 comments on commit 763afc1

Please sign in to comment.