Class GameGate

java.lang.Object
edu.ucsb.cs156.happiercows.jobs.GameGate

public class GameGate extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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).
    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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 process
      gameRepository - repository used to save the game when it is auto-hidden
      ctx - 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 process
      gameRepository - repository used to save the game when it is auto-hidden
      ctx - the job context, for logging
      now - 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