Skip to content

Commit

Permalink
Merge pull request #180 from SSchulze1989/develop
Browse files Browse the repository at this point in the history
v 0.10.1
  • Loading branch information
SSchulze1989 authored Oct 31, 2023
2 parents 00d71ae + 58f2e27 commit 130c543
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/iRLeagueApiCore.Client/iRLeagueApiCore.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<OutputType>Library</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<PackageId>iRLeagueApiCore.Client</PackageId>
<Version>0.10.0</Version>
<Version>0.10.1</Version>
<Authors>Simon Schulze</Authors>
<Company>Simon Schulze</Company>
<PackageDescription>This package contains shared objects for all members of the iRLeagueDatabase-iRLeagueApi stack</PackageDescription>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private async Task<ResultRowEntity> ReadResultRowAsync(long leagueId, ParseSimSe
FastLapNr = data.best_lap_num,
FinishPosition = data.position + 1,
Incidents = data.incidents,
Interval = ParseInterval(data.interval, data.laps_complete, laps),
Interval = ParseInterval(data.class_interval, data.laps_complete, laps),
IRacingId = data.cust_id.ToString(),
LeadLaps = data.laps_lead,
License = sessionData.license_category,
Expand Down
2 changes: 1 addition & 1 deletion src/iRLeagueApiCore.Server/iRLeagueApiCore.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Version>0.10.0</Version>
<Version>0.10.1</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protected static IEnumerable<ResultRowCalculationResult> ApplyPoints(IEnumerable
rows = pointRule.GetChampSeasonFilters().FilterRows(rows);
rows = pointRule.GetResultFilters().FilterRows(rows);
rows = CalculateCompletedPct(rows);
rows = CalculateIntervals(rows);
rows = CalculateAutoPenalties(rows, pointRule.GetAutoPenalties());
ApplyAddPenaltyDsq(rows);
ApplyAddPenaltyTimes(rows);
Expand Down Expand Up @@ -445,4 +446,17 @@ protected static IEnumerable<ResultRowCalculationResult> CalculateCompletedPct(I

return rows;
}

private static IEnumerable<ResultRowCalculationResult> CalculateIntervals(IEnumerable<ResultRowCalculationResult> rows)
{
int totalLaps = (int)rows.Max(x => x.CompletedLaps);
foreach (var row in rows)
{
if (row.Interval.Days > 0)
{
row.Interval = TimeSpan.FromDays(totalLaps - row.CompletedLaps);
}
}
return rows;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public async Task Calculate_ShouldApplyTeamPenalties(PenaltyType penaltyType)
break;
case PenaltyType.Time:
var interval = TimeSpan.FromSeconds(testTeamRows.Sum(x => x.Interval.TotalSeconds));
testRow.Interval.Should().Be(interval + penalty.Time);
testRow.Interval.Should().BeCloseTo(interval + penalty.Time, TimeSpan.FromSeconds(0.001));
break;
case PenaltyType.Position:
var position = test.ResultRows.OrderBy(x => x.TeamId).ToList().IndexOf(testRow) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public async Task Handle_ShouldFillResultRowData()
testRow.FastLapNr.Should().Be(resultRow.best_lap_num);
testRow.FinishPosition.Should().Be(resultRow.position+1);
testRow.Incidents.Should().Be(resultRow.incidents);
testRow.Interval.Should().Be(TimeSpan.FromSeconds(resultRow.interval / 10000D));
testRow.Interval.Should().Be(TimeSpan.FromSeconds(resultRow.class_interval / 10000D));
testRow.IRacingId.Should().Be(resultRow.cust_id.ToString());
testRow.LeadLaps.Should().Be(resultRow.laps_lead);
testRow.Member.IRacingId.Should().Be(resultRow.cust_id.ToString());
Expand Down Expand Up @@ -386,7 +386,7 @@ public async Task Handle_ShouldGetIntervalLaps_WhenIntervalIsNegative()
result.session_results[0].results.First().laps_complete = maxLaps;
var lapsDown = 3;
var setupRow = result.session_results[0].results.Last();
setupRow.interval = -1;
setupRow.class_interval = -1;
setupRow.laps_complete = maxLaps - lapsDown;
var request = CreateRequest(@event.EventId, result);
var sut = CreateSut();
Expand Down Expand Up @@ -436,7 +436,7 @@ public async Task Handle_ShouldFillResultRowData_FromTeamResults()
testRow.FastLapNr.Should().Be(resultRow.best_lap_num);
testRow.FinishPosition.Should().Be(resultRow.position + 1);
testRow.Incidents.Should().Be(resultRow.incidents);
testRow.Interval.Should().Be(TimeSpan.FromSeconds(resultRow.interval / 10000D));
testRow.Interval.Should().Be(TimeSpan.FromSeconds(resultRow.class_interval / 10000D));
testRow.IRacingId.Should().Be(resultRow.cust_id.ToString());
testRow.LeadLaps.Should().Be(resultRow.laps_lead);
testRow.Member.IRacingId.Should().Be(resultRow.cust_id.ToString());
Expand Down

0 comments on commit 130c543

Please sign in to comment.