Files
MatchLiveTv/backend/app/services/teams/generate_slug.rb
T
eminuxandCursor 1d97271555 Aggiunge i18n IT/EN/FR/DE/ES, pagine pubbliche squadre e UX archivio.
Il selettore lingua funziona sul web e sulle app native; su Android la preferenza è persistita e applicata al riavvio. Incluse anche eliminazione replay a scope e campi pagina pubblica squadra.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 19:30:44 +02:00

31 lines
527 B
Ruby

module Teams
class GenerateSlug
def self.call(team)
new(team).call
end
def initialize(team)
@team = team
end
def call
base = @team.name.to_s.parameterize.presence || "squadra"
slug = base
n = 2
while conflict?(slug)
slug = "#{base}-#{n}"
n += 1
end
slug
end
private
def conflict?(slug)
scope = Team.where(slug: slug)
scope = scope.where.not(id: @team.id) if @team.persisted?
scope.exists?
end
end
end