Billing Stripe, link regia mobile e staff solo trasmissione.
Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,17 +7,47 @@ class Match < ApplicationRecord
|
||||
validates :opponent_name, presence: true
|
||||
validates :sets_to_win, numericality: { greater_than: 0, less_than: 6 }
|
||||
|
||||
scope :scheduled_upcoming, -> {
|
||||
where.not(scheduled_at: nil).where("scheduled_at >= ?", Time.current)
|
||||
# Partite con data/ora: da inizio giornata (Europe/Rome) in poi — allineato alla pagina Partite.
|
||||
scope :scheduled_for_live, -> {
|
||||
where.not(scheduled_at: nil).where("scheduled_at >= ?", Time.zone.now.beginning_of_day)
|
||||
}
|
||||
|
||||
scope :scheduled_upcoming, -> { scheduled_for_live }
|
||||
|
||||
def scheduled_upcoming?
|
||||
scheduled_at.present? && scheduled_at >= Time.zone.now
|
||||
end
|
||||
|
||||
def scheduled_on_calendar?
|
||||
scheduled_at.present? && scheduled_at >= Time.zone.now.beginning_of_day
|
||||
end
|
||||
|
||||
def active_stream_session
|
||||
stream_sessions.sort_by { |s| s.created_at }.reverse
|
||||
.find { |s| !%w[ended error].include?(s.status) }
|
||||
end
|
||||
|
||||
def deletable?
|
||||
session = active_stream_session
|
||||
session.nil? || !session.resumable?
|
||||
end
|
||||
|
||||
def public_status_label
|
||||
active = active_stream_session
|
||||
return "In corso / da riprendere" if active
|
||||
return "Programmata" if scheduled_upcoming?
|
||||
return "Pronta" if scheduled_at.present?
|
||||
|
||||
"Senza orario"
|
||||
end
|
||||
|
||||
scope :search_teams_or_opponents, lambda { |query|
|
||||
q = query.to_s.strip
|
||||
return all if q.blank?
|
||||
|
||||
term = "%#{sanitize_sql_like(q)}%"
|
||||
joins(:team).where(
|
||||
"teams.name ILIKE :term OR matches.opponent_name ILIKE :term",
|
||||
joins(team: :club).where(
|
||||
"teams.name ILIKE :term OR matches.opponent_name ILIKE :term OR clubs.name ILIKE :term OR matches.location ILIKE :term",
|
||||
term: term
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user