# frozen_string_literal: true require 'rom-repository' module EuchreCamp module Repositories class TournamentRounds < ::EuchreCamp::Repository[:tournament_rounds] commands :create, update: :by_pk, delete: :by_pk def by_event(event_id) tournament_rounds.where(event_id: event_id).order(:round_number).to_a end def current_round(event_id) tournament_rounds .where(event_id: event_id, status: 'active') .order(Sequel.desc(:round_number)) .one end def next_round(event_id) tournament_rounds .where(event_id: event_id, status: 'pending') .order(:round_number) .limit(1) .one end end end end