Update show for puzzle and chapter
This commit is contained in:
parent
fe904774c0
commit
772dd2d23f
4 changed files with 5 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue