Skip to content

Commit

Permalink
Fix: Fixtures for teams playing in same round and using same venue (#91)
Browse files Browse the repository at this point in the history
When creating fixtures automatically, in case

* 2 (or more) teams play in the same round
* all teams use the same venue
* the venue is used at the same day of the week

Match days will now be assigned to all teams on a rotating basis for the venue.
  • Loading branch information
axunonb authored Jul 24, 2023
1 parent cf0856d commit 093d88f
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 223 deletions.
11 changes: 5 additions & 6 deletions Axuno.Tools/GermanFederalStates.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

Expand Down Expand Up @@ -68,11 +67,11 @@ public GermanFederalStates()
{
try
{
Contains(this[stateId]);
_ = Contains(this[stateId]);
}
catch
{
throw new Exception(string.Format("GermanFederalStateId \"{0}\" wird in \"{1}\" nicht abgebildet.", stateId, GetType()));
throw new Exception($"GermanFederalStateId \"{stateId}\" is not included in \"{GetType()}\".");
}
}
#endif
Expand All @@ -88,8 +87,8 @@ public GermanFederalStates()
/// <summary>
/// Get a GermanFederalState object.
/// </summary>
/// <param name="nameOrAbbreviation">State abbriviation or state name.</param>
/// <returns>Returns the GermanFederalState for the state abbriviation or state name.</returns>
/// <param name="nameOrAbbreviation">State abbreviation or state name.</param>
/// <returns>Returns the GermanFederalState for the state abbreviation or state name.</returns>
public GermanFederalState this[string nameOrAbbreviation]
{
get
Expand All @@ -100,4 +99,4 @@ public GermanFederalState this[string nameOrAbbreviation]
return this.First(fs => fs.Name == nameOrAbbreviation);
}
}
}
}
4 changes: 2 additions & 2 deletions Axuno.Tools/GermanHolidays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public bool IsPublicHoliday(GermanFederalStates.Id stateId)

public static bool operator ==(GermanHoliday? h1, GermanHoliday? h2)
{
if (h1 == null || h2 == null) return false;
if (h1 is null || h2 is null) return false;
return h1.Equals(h2);
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public GermanHolidays(int year)
{
// Plausibility check
if (year < 1583 || year > 4099)
throw new Exception("Year must be between 1583 and 4099.");
throw new ArgumentException("Year must be between 1583 and 4099.", nameof(year));

Year = year;
_easterSunday = GetEasterSunday();
Expand Down
159 changes: 0 additions & 159 deletions TournamentManager/TournamentManager/Assets/Holidays.A-Indoor.config

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace TournamentManager.Data;

/// <summary>
/// Class for ExcludedMatchDate related data selections
/// Class for database operations for available match dates.
/// </summary>
public class AvailableMatchDateRepository
{
Expand Down Expand Up @@ -47,8 +47,6 @@ public async Task<EntityCollection<AvailableMatchDateEntity>> GetAvailableMatchD
await da.FetchEntityCollectionAsync(qp, cancellationToken);
da.CloseConnection();

_logger.LogDebug("{count} available match dates found", available.Count);

return available;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ExcludedMatchDateRepository
public ExcludedMatchDateRepository(MultiTenancy.IDbContext dbContext)
{
_dbContext = dbContext;
_logger.LogDebug("Repository created. {Repository} {Identifier}", nameof(TournamentRepository), dbContext.Tenant?.Identifier);
}

/// <summary>
Expand All @@ -47,8 +48,6 @@ public async Task<EntityCollection<ExcludeMatchDateEntity>> GetExcludedMatchDate
await da.FetchEntityCollectionAsync(qp, cancellationToken);
da.CloseConnection();

_logger.LogDebug("{count} excluded match dates found", excluded.Count);

return excluded;
}

Expand Down Expand Up @@ -98,4 +97,4 @@ public async Task<EntityCollection<ExcludeMatchDateEntity>> GetExcludedMatchDate
.AddWithOr(roundFilter).AddWithOr(teamFilter)).Limit(1),
cancellationToken)).Cast<ExcludeMatchDateEntity>().FirstOrDefault();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TournamentRepository
public TournamentRepository(MultiTenancy.IDbContext dbContext)
{
_dbContext = dbContext;
_logger.LogDebug("{repository} created.", nameof(TournamentRepository));
_logger.LogDebug("Repository created. {Repository} {Identifier}", nameof(TournamentRepository), dbContext.Tenant?.Identifier);
}

[Obsolete("Use GetTournamentAsync instead", false)]
Expand Down Expand Up @@ -95,4 +95,4 @@ public virtual EntityCollection<RoundEntity> GetTournamentRounds(long tournament
await da.FetchEntityCollectionAsync(qp, cancellationToken);
return t.FirstOrDefault();
}
}
}
Loading

0 comments on commit 093d88f

Please sign in to comment.