This commit is contained in:
jeffcheasey88 2023-09-16 12:17:47 +02:00
commit 3da54bbe17
4 changed files with 5 additions and 6 deletions

View file

@ -35,11 +35,10 @@ public class Chapter {
this.puzzles = puzzles;
}
public boolean isInCurrentTime(){
public boolean hasStarted(){
LocalDateTime now = LocalDateTime.now();
boolean show = true;
if(startDate != null) show &= now.isAfter(startDate.toLocalDateTime());
if(endDate != null) show &= now.isBefore(endDate.toLocalDateTime());
return show;
}

View file

@ -86,7 +86,7 @@ public class Puzzle {
return this.depend;
}
public boolean isInCurrentTime(){
public boolean hasStarted(){
LocalDateTime now = LocalDateTime.now();
boolean show = true;
if(startDate != null) show &= now.isAfter(startDate.toLocalDateTime());

View file

@ -33,7 +33,7 @@ public class ChapterElement implements Response {
JsonMap chapterJSON = new JsonMap();
chapterJSON.set("id", chapter.getId());
chapterJSON.set("name", chapter.getName());
boolean show = chapter.isInCurrentTime();
boolean show = chapter.hasStarted();
chapterJSON.set("show", show);
PeerAtUser user = context.getUser();
if(show){
@ -46,7 +46,7 @@ public class ChapterElement implements Response {
if (puzzle.getTags() != null) puzzleJSON.set("tags", puzzle.getJsonTags());
int score = this.databaseRepo.getScore(user.getId(), puzzle.getId());
if(score >= 0) puzzleJSON.set("score", score);
puzzleJSON.set("show", puzzle.isInCurrentTime());
puzzleJSON.set("show", puzzle.hasStarted());
puzzles.add(puzzleJSON);
}
chapterJSON.set("puzzles", puzzles);

View file

@ -34,7 +34,7 @@ public class ChapterList implements Response {
JsonMap chapterJSON = new JsonMap();
chapterJSON.set("id", chapter.getId());
chapterJSON.set("name", chapter.getName());
chapterJSON.set("show", chapter.isInCurrentTime());
chapterJSON.set("show", chapter.hasStarted());
chaptersJSON.add(chapterJSON);
}
context.response(200);