Skip to content

Commit

Permalink
Fix #1074 and part of #1075 (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil authored Aug 26, 2024
1 parent 2cf01cb commit 66b7662
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion c-sharp/Checks/CheckResultsRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void RecordError(
{
var chapterVerse = token.ScrRefString.Split(":");
int chapterNumber = int.Parse(chapterVerse[0]);
int verseNumber = int.Parse(chapterVerse[1]);
int verseNumber = GetVerseNumber(chapterVerse[1]);
VerseRef verseRef = new (CurrentBookNumber, chapterNumber, verseNumber);
CheckRunResults.Add(new CheckRunResult(
checkId,
Expand Down Expand Up @@ -58,4 +58,25 @@ public void RecordError(
}

public List<CheckRunResult> CheckRunResults { get; } = [];

private static int GetVerseNumber(string verseNumber)
{
ArgumentException.ThrowIfNullOrWhiteSpace(verseNumber);
if (!IsDigit(verseNumber[0]))
throw new ArgumentException($"verseNumber must start with an integer: {verseNumber}");

int lastIndex = 1;
while (lastIndex < verseNumber.Length)
{
if (!IsDigit(verseNumber[lastIndex]))
break;
lastIndex++;
}
return int.Parse(verseNumber[..lastIndex]);
}

private static bool IsDigit(char c)
{
return c >= '0' && c <= '9';
}
}
7 changes: 7 additions & 0 deletions c-sharp/Checks/CheckRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ private ResponseToRequest GetCheckResults()
var retVal = new List<CheckRunResult>();
foreach (var check in _checksByIds.Values)
retVal.AddRange(check.ResultsRecorder.CheckRunResults);
if (retVal.Count > 1000)
{
var fullCount = retVal.Count;
retVal.RemoveRange(1000, fullCount - 1000);
retVal.TrimExcess();
Console.WriteLine($"Trimming {fullCount} check results to 1000");
}
Console.WriteLine($"Returning {retVal.Count} check results");
return ResponseToRequest.Succeeded(retVal);
}
Expand Down

0 comments on commit 66b7662

Please sign in to comment.