feat(tournament-suggestions): implement save functionality for tournament suggestions
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 8m44s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 8m44s
This commit is contained in:
@@ -7,10 +7,36 @@ import OfficialTournament from '../models/OfficialTournament.js';
|
||||
import OfficialCompetition from '../models/OfficialCompetition.js';
|
||||
import OfficialCompetitionMember from '../models/OfficialCompetitionMember.js';
|
||||
import OfficialTournamentTacticPlan from '../models/OfficialTournamentTacticPlan.js';
|
||||
import TournamentSuggestion from '../models/TournamentSuggestion.js';
|
||||
import Member from '../models/Member.js';
|
||||
import OfficialTournamentParserService from './officialTournamentParserService.js';
|
||||
|
||||
class OfficialTournamentService {
|
||||
async saveTournamentSuggestion(clubId, suggestionId) {
|
||||
const suggestion = await TournamentSuggestion.findOne({ where: { id: suggestionId, clubId } });
|
||||
if (!suggestion) return null;
|
||||
|
||||
let tournament = await OfficialTournament.findOne({
|
||||
where: { clubId, title: suggestion.title, eventDate: suggestion.eventDate },
|
||||
});
|
||||
const created = !tournament;
|
||||
if (!tournament) {
|
||||
tournament = await OfficialTournament.create({
|
||||
clubId,
|
||||
title: suggestion.title,
|
||||
eventDate: suggestion.eventDate,
|
||||
organizer: suggestion.organizer,
|
||||
host: suggestion.organizer,
|
||||
venues: JSON.stringify(suggestion.location ? [suggestion.location] : []),
|
||||
competitionTypes: JSON.stringify([]),
|
||||
registrationDeadlines: JSON.stringify([]),
|
||||
entryFees: JSON.stringify({}),
|
||||
});
|
||||
}
|
||||
await suggestion.update({ status: 'reviewed' });
|
||||
return { id: String(tournament.id), created };
|
||||
}
|
||||
|
||||
async listTacticPlans(clubId, tournamentId) {
|
||||
const tournament = await OfficialTournament.findOne({ where: { id: tournamentId, clubId } });
|
||||
if (!tournament) return null;
|
||||
|
||||
Reference in New Issue
Block a user