From 989a4a7a3300bb9f4c31c8f8f4f9231c89473acb Mon Sep 17 00:00:00 2001 From: patrick Date: Sat, 21 Oct 2023 00:39:54 +0000 Subject: [PATCH] Deal with total people suffix (#2) Co-authored-by: Smaug123 Reviewed-on: https://gitea.patrickstevens.co.uk/patrick/puregym-unofficial-dotnet/pulls/2 --- PureGym/Api.fs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PureGym/Api.fs b/PureGym/Api.fs index 274ce85..a98a6e8 100644 --- a/PureGym/Api.fs +++ b/PureGym/Api.fs @@ -177,6 +177,7 @@ type GymAttendance = /// How many people are in classes at the gym as of this statistics snapshot [] TotalPeopleInClasses : int + /// E.g. " or fewer" TotalPeopleSuffix : string [] 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"}"""