Deal with total people suffix (#2)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful

Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #2
This commit is contained in:
2023-10-21 00:39:54 +00:00
parent 80e7947ae2
commit 989a4a7a33

View File

@@ -177,6 +177,7 @@ type GymAttendance =
/// How many people are in classes at the gym as of this statistics snapshot
[<JsonRequired>]
TotalPeopleInClasses : int
/// E.g. " or fewer"
TotalPeopleSuffix : string
[<JsonRequired>]
IsApproximate : bool
@@ -192,8 +193,10 @@ type GymAttendance =
/// Human-readable representation
override this.ToString () =
if not (Object.ReferenceEquals (this.TotalPeopleSuffix, null)) then
failwith $"Unexpectedly got Total People Suffix: %s{this.TotalPeopleSuffix}"
let totalPeopleSuffix =
match this.TotalPeopleSuffix with
| null -> ""
| suffix -> suffix
let capacity =
if this.MaximumCapacity = 0 then
@@ -207,7 +210,7 @@ type GymAttendance =
else
$"\n%i{this.TotalPeopleInClasses} in classes"
$"""%i{this.TotalPeopleInGym} in gym%s{capacity} (is exact: %c{Char.emoji (not this.IsApproximate)})%s{classes}
$"""%i{this.TotalPeopleInGym}%s{totalPeopleSuffix} in gym%s{capacity} (is exact: %c{Char.emoji (not this.IsApproximate)})%s{classes}
Query made at %s{this.AttendanceTime.ToString "s"}%s{this.AttendanceTime.ToString "zzz"}
Snapshot correct as of %s{this.LastRefreshed.ToString "s"}%s{this.LastRefreshed.ToString "zzz"}
Classes info correct as of %s{this.LastRefreshedPeopleInClasses.ToString "s"}%s{this.LastRefreshedPeopleInClasses.ToString "zzz"}"""