Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,21 @@ public async Task Turnierplan_Client_Works_As_Expected_With_Test_Server()
new Ranking
{
PlacementRank = 1,
Reason = RankingReason.RankingViaGroupResults,
IsDefined = false,
TeamId = null
},
new Ranking
{
PlacementRank = 2,
Reason = RankingReason.RankingViaGroupResults,
IsDefined = false,
TeamId = null
},
new Ranking
{
PlacementRank = 3,
Reason = RankingReason.RankingViaGroupResults,
IsDefined = false,
TeamId = null
}
Expand Down
82 changes: 82 additions & 0 deletions src/Turnierplan.Adapter/Enums/RankingReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
namespace Turnierplan.Adapter.Enums;

/// <summary>
/// Represents the reason of team selection for a single ranking.
/// </summary>
public enum RankingReason
{
/// <summary>
/// The ranking is defined by the winner of the final match.
/// </summary>
WinnerOfFinal,

/// <summary>
/// The ranking is defined by the loser of the final match.
/// </summary>
LoserOfFinal,

/// <summary>
/// The ranking is defined by the winner of the 3rd place playoff match.
/// </summary>
WinnerOfThirdPlacePlayoff,

/// <summary>
/// The ranking is defined by the loser of the 3rd place playoff match.
/// </summary>
LoserOfThirdPlacePlayoff,

/// <summary>
/// The ranking is defined by the winner of any additional (5th, 7th, ...) playoff match.
/// </summary>
WinnerOfAdditionalPlayoff,

/// <summary>
/// The ranking is defined by the loser of any additional (5th, 7th, ...) playoff match.
/// </summary>
LoserOfAdditionalPlayoff,

/// <summary>
/// The ranking is defined by a team which has qualified for the semi-finals but did not qualify for any further
/// round or playoff match. If multiple rankings have this reason assigned, the teams will be sorted amongst each
/// other by their relative success in the semi-final matches and then by their group statistics.
/// </summary>
QualifiedForSemiFinals,

/// <summary>
/// The ranking is defined by a team which has qualified for the quarter-finals but did not qualify for any further
/// round or playoff match. If multiple rankings have this reason assigned, the teams will be sorted amongst each
/// other by their relative success in the quarter-final matches and then by their group statistics.
/// </summary>
QualifiedForQuarterFinals,

/// <summary>
/// The ranking is defined by a team which has qualified for the eighth-finals but did not qualify for any further
/// round or playoff match. If multiple rankings have this reason assigned, the teams will be sorted amongst each
/// other by their relative success in the eighth-final matches and then by their group statistics.
/// </summary>
QualifiedForEighthFinals,

/// <summary>
/// The ranking is defined by a team which has qualified any finals round broader than eighth-finals (such as 16th, 32nd, ...)
/// but did not qualify for any further round or playoff match. If multiple rankings have this reason assigned, the teams will
/// be sorted amongst each other by their relative success in that finals round's matches and then by their group statistics.
/// </summary>
QualifiedForBroaderFinals,

/// <summary>
/// The ranking is defined by a team which has not qualified for any finals round at all. If multiple rankings have this
/// reason assigned, the teams will be sorted amongst each other by their group statistics.
/// </summary>
/// <seealso cref="RankingViaGroupResults" />
NotQualifiedForFinals,

/// <summary>
/// Used instead of <see cref="NotQualifiedForFinals"/> if the tournament does not contain any finals/playoff matches.
/// </summary>
RankingViaGroupResults,

/// <summary>
/// The ranking is defined manually.
/// </summary>
ManuallyChanged
}
9 changes: 8 additions & 1 deletion src/Turnierplan.Adapter/Models/Ranking.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using Turnierplan.Adapter.Enums;

namespace Turnierplan.Adapter.Models;

/// <summary>
/// A ranking in the context of a <see cref="Tournament"/>. There are equally many rankings in a tournament as there are teams.
/// A ranking in the context of a <see cref="Tournament"/>. The number of rankings can differ from the number of teams.
/// Also, the sequence of <see cref="PlacementRank"/> does not necessarily have to start at 1, and it may also contain gaps.
/// </summary>
public sealed record Ranking
{
Expand All @@ -12,6 +14,11 @@ public sealed record Ranking
/// </summary>
public required int PlacementRank { get; init; }

/// <summary>
/// The reason is a short explanation of why the specific team is selected / will be selected for this ranking position.
/// </summary>
public required RankingReason Reason { get; init; }

/// <summary>
/// Whether this ranking is currently defined or not.
/// </summary>
Expand Down
17 changes: 16 additions & 1 deletion src/Turnierplan.App/Client/src/app/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,22 @@ export const de = {
TableLabel: 'Endplatzierungen des Turniers',
NoRankings: 'Keine Platzierungen vorhanden',
Position: 'Position',
Team: 'Mannschaft'
Team: 'Mannschaft',
Reasons: {
WinnerOfFinal: 'Sieger vom Finale',
LoserOfFinal: 'Verlierer vom Finale',
WinnerOfThirdPlacePlayoff: 'Sieger vom Spiel um Platz 3',
LoserOfThirdPlacePlayoff: 'Verlierer vom Spiel um Platz 3',
WinnerOfAdditionalPlayoff: 'Sieger von zusätzlichem Platzierungsspiel',
LoserOfAdditionalPlayoff: 'Verlierer von zusätzlichem Platzierungsspiel',
QualifiedForSemiFinals: 'Qualifiziert für Halbfinale',
QualifiedForQuarterFinals: 'Qualifiziert für Viertelfinale',
QualifiedForEighthFinals: 'Qualifiziert für Achtelfinale',
QualifiedForBroaderFinals: 'Qualifiziert für andere Finalrunde',
NotQualifiedForFinals: 'Nicht qualifiziert für Finalrunde',
RankingViaGroupResults: 'Platzierung nach Gruppenergebnissen',
ManuallyChanged: 'Manuell bearbeitet'
}
},
Documents: {
Name: 'Name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
<tr>
<th translate="Portal.ViewTournament.Ranking.Position"></th>
<th translate="Portal.ViewTournament.Ranking.Team"></th>
<th></th>
</tr>
</thead>
<tbody>
@for (ranking of rankings; track ranking.position) {
<tr>
<td>{{ ranking.position }}</td>
<td [tpE2E]="['view-tournament-page-ranking-team-name', ranking.position]">{{ ranking.team }}</td>
<td class="align-middle small text-secondary" [translate]="'Portal.ViewTournament.Ranking.Reasons.' + ranking.reason"></td>
</tr>
} @empty {
<tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Component, Input } from '@angular/core';
import { TranslateDirective, TranslatePipe } from '@ngx-translate/core';
import { E2eDirective } from '../../../core/directives/e2e.directive';
import { RankingReason } from '../../../api/models/ranking-reason';

export interface RankingView {
position: number;
team: string;
reason: RankingReason;
}

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,8 @@ export class ViewTournamentComponent implements OnInit, OnDestroy {
}
return {
position: ranking.placementRank,
team: teamName
team: teamName,
reason: ranking.reason
};
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Turnierplan.App/Mapping/Rules/TournamentMappingRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected override TournamentDto Map(IMapper mapper, MappingContext context, Tou
return new RankingDto
{
PlacementRank = entry.Position,
Reason = entry.Reason,
IsDefined = entry.IsDefined,
TeamId = entry.Team?.Id
};
Expand Down
4 changes: 4 additions & 0 deletions src/Turnierplan.App/Models/RankingDto.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Turnierplan.Core.Tournament;

namespace Turnierplan.App.Models;

public sealed record RankingDto
{
public required int PlacementRank { get; init; }

public required RankingReason Reason { get; init; }

public required bool IsDefined { get; init; }

public required int? TeamId { get; init; }
Expand Down
Loading
Loading