Skip to content

Commit

Permalink
Merge branch 'develop' into admin-view
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelayori authored Apr 26, 2024
2 parents 6b8b6dc + eec984f commit 35ecb0f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/uniovi/services/QuestionGeneratorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public class QuestionGeneratorService {

private Logger log = LoggerFactory.getLogger(InsertSampleDataService.class);

private boolean started;

public QuestionGeneratorService(QuestionService questionService) {
this.questionService = questionService;
((QuestionServiceImpl)questionService).setQuestionGeneratorService(this);
parseQuestionTypes();
this.started = true;
}

private void parseQuestionTypes() {
Expand All @@ -67,13 +70,22 @@ private void parseQuestionTypes() {
}
}

@Scheduled(fixedRate = 86400000, initialDelay = 86400000)
public void generateAllQuestions(){
}

@Scheduled(fixedRate = 150000)
@Transactional
public void generateQuestions() throws IOException {
if (types.isEmpty()) {
return;
}

if (started){
started = false;
questionService.deleteAllQuestions();
}

if (Arrays.stream(environment.getActiveProfiles()).anyMatch(env -> (env.equalsIgnoreCase("test")))) {
log.info("Test profile active, skipping sample data insertion");
return;
Expand Down

0 comments on commit 35ecb0f

Please sign in to comment.