Class GameGate
java.lang.Object
edu.ucsb.cs156.happiercows.jobs.GameGate
A shared gate used by every job (scheduled or on demand) that operates on a
game: jobs should only touch games that are in progress (see
Game.gameInProgress(LocalDateTime)).
As a side effect, when a game whose end date has passed is encountered,
it is automatically hidden (see issue #250).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanshouldProcess(Game game, GameRepository gameRepository, edu.ucsb.cs156.jobs.services.JobContext ctx) Determine whether a job should process the given game, using the current Pacific time as "now" - see issue #318 (the JVM's own default timezone isn't guaranteed to be Pacific).static booleanshouldProcess(Game game, GameRepository gameRepository, edu.ucsb.cs156.jobs.services.JobContext ctx, LocalDateTime now) Determine whether a job should process the given game as of the given instant.
-
Constructor Details
-
GameGate
public GameGate()
-
-
Method Details
-
shouldProcess
public static boolean shouldProcess(Game game, GameRepository gameRepository, edu.ucsb.cs156.jobs.services.JobContext ctx) Determine whether a job should process the given game, using the current Pacific time as "now" - see issue #318 (the JVM's own default timezone isn't guaranteed to be Pacific).- Parameters:
game- the game the job wants to processgameRepository- repository used to save the game when it is auto-hiddenctx- the job context, for logging- Returns:
- true if the game is in progress and the job should proceed
-
shouldProcess
public static boolean shouldProcess(Game game, GameRepository gameRepository, edu.ucsb.cs156.jobs.services.JobContext ctx, LocalDateTime now) Determine whether a job should process the given game as of the given instant. If the game is not in progress, a skip message is logged; additionally, if the game has ended and the game is not yet hidden, it is hidden and saved.- Parameters:
game- the game the job wants to processgameRepository- repository used to save the game when it is auto-hiddenctx- the job context, for loggingnow- the current time, as of which to evaluate the game's status- Returns:
- true if the game is in progress and the job should proceed
-