Class DrillItemDao

java.lang.Object
me.nickhanson.codeforge.persistence.DrillItemDao

public class DrillItemDao extends Object
DAO for DrillItem entity. Provides generic CRUD operations and entity-specific queries.
Author:
Nick Hanson
  • Constructor Details

    • DrillItemDao

      public DrillItemDao()
  • Method Details

    • getById

      public DrillItem getById(Long id)
    • getAll

      public List<DrillItem> getAll()
    • saveOrUpdate

      public void saveOrUpdate(DrillItem item)
    • delete

      public void delete(DrillItem item)
    • listByChallengeId

      public List<DrillItem> listByChallengeId(Long challengeId)
      List all DrillItems for a given Challenge ID, ordered by nextDueAt ascending.
      Parameters:
      challengeId - the ID of the Challenge
      Returns:
      list of DrillItems associated with the Challenge
    • dueNow

      public List<DrillItem> dueNow(Instant now)
      List all DrillItems that are due at or before the specified time.
      Parameters:
      now - the cutoff Instant for due items
      Returns:
      list of due DrillItems
    • countDue

      public long countDue(Instant now)
      Count of DrillItems that are due at or before the specified time.
      Parameters:
      now - the cutoff Instant for due items
      Returns:
      count of due DrillItems
    • bulkReschedule

      public int bulkReschedule(List<Long> ids, Instant nextDueAt)
      Bulk reschedule DrillItems by setting their nextDueAt to the specified time.
      Parameters:
      ids - list of DrillItem IDs to reschedule
      nextDueAt - the new nextDueAt Instant
      Returns:
      number of items updated
    • dueQueue

      public List<DrillItem> dueQueue(Instant now, int limit)
      List of due DrillItems up to the specified limit, ordered by nextDueAt.
      Parameters:
      now - the cutoff Instant for due items
      limit - maximum number of items to return
      Returns:
      list of due DrillItems
    • soonestUpcoming

      public Optional<DrillItem> soonestUpcoming()
      Find the DrillItem with the soonest upcoming nextDueAt.
      Returns:
      Optional containing the soonest upcoming DrillItem, or empty if none exist
    • listByChallengeIdAndUser

      public List<DrillItem> listByChallengeIdAndUser(Long challengeId, String userId)
      List all DrillItems for a given Challenge ID and user, ordered by nextDueAt ascending.
      Parameters:
      challengeId - the ID of the Challenge
      userId - the ID of the User
      Returns:
      list of DrillItems associated with the Challenge and User
    • dueNow

      public List<DrillItem> dueNow(Instant now, String userId)
      List all DrillItems that are due at or before the specified time for a specific user.
      Parameters:
      now - the cutoff Instant for due items
      userId - the ID of the User
      Returns:
      list of due DrillItems for the User
    • countDue

      public long countDue(Instant now, String userId)
      Count of DrillItems that are due at or before the specified time for a specific user.
      Parameters:
      now - the cutoff Instant for due items
      userId - the ID of the User
      Returns:
      count of due DrillItems for the User
    • dueQueue

      public List<DrillItem> dueQueue(Instant now, int limit, String userId)
      User-scoped due queue up to the specified limit, ordered by nextDueAt.
      Parameters:
      now - the cutoff Instant for due items
      limit - maximum number of items to return
      userId - the ID of the User
      Returns:
      list of due DrillItems for the User
    • soonestUpcoming

      public Optional<DrillItem> soonestUpcoming(String userId)
      Find the soonest upcoming DrillItem for a user.
      Parameters:
      userId - the ID of the User
      Returns:
      Optional containing the soonest upcoming DrillItem for the User, or empty if none exist