Better semantics for MemberActivity (#1)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk> Reviewed-on: #1
This commit is contained in:
@@ -168,6 +168,7 @@ type Member =
|
||||
/// Statistics for how many people are currently at a gym
|
||||
type GymAttendance =
|
||||
{
|
||||
/// This appears always to be just equal to TotalPeopleInGym, but a string.
|
||||
[<JsonRequired>]
|
||||
Description : string
|
||||
/// How many people are in the gym as of this statistics snapshot
|
||||
@@ -207,25 +208,55 @@ type GymAttendance =
|
||||
$"\n%i{this.TotalPeopleInClasses} in classes"
|
||||
|
||||
$"""%i{this.TotalPeopleInGym} 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")}"""
|
||||
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"}"""
|
||||
|
||||
/// The visit statistics for a particular human to a particular gym.
|
||||
/// The semantics of this class are basically unknown.
|
||||
type MemberActivity =
|
||||
type MemberActivityThisMonth =
|
||||
{
|
||||
/// ??? semantics unknown; this was 2852 for me
|
||||
[<JsonPropertyName "totalDuration">]
|
||||
/// How many minutes, including classes, have been logged so far this month
|
||||
TotalDurationMinutes : int
|
||||
[<JsonPropertyName "averageDuration">]
|
||||
/// How long, in minutes, each visit has been on average this month
|
||||
AverageDurationMinutes : int
|
||||
/// How many visits have been made this month, excluding classes
|
||||
TotalVisits : int
|
||||
/// How many classes have been attended this month
|
||||
TotalClasses : int
|
||||
/// Whether this block of statistics is estimated rather than exact
|
||||
IsEstimated : bool
|
||||
/// When this data was constructed
|
||||
LastRefreshed : DateTime
|
||||
}
|
||||
|
||||
/// Don't use this type. It's public because System.Text.Json can't do private types.
|
||||
type MemberActivityDto =
|
||||
{
|
||||
[<JsonRequired>]
|
||||
TotalDuration : int
|
||||
[<JsonRequired>]
|
||||
AverageDuration : int
|
||||
[<JsonRequired>]
|
||||
TotalVisits : int
|
||||
[<JsonRequired>]
|
||||
TotalClasses : int
|
||||
[<JsonRequired>]
|
||||
IsEstimated : bool
|
||||
[<JsonRequired>]
|
||||
LastRefreshed : DateTime
|
||||
}
|
||||
|
||||
member this.ToMemberActivity () =
|
||||
{
|
||||
TotalDurationMinutes = this.TotalDuration
|
||||
AverageDurationMinutes = this.AverageDuration
|
||||
TotalVisits = this.TotalVisits
|
||||
TotalClasses = this.TotalClasses
|
||||
IsEstimated = this.IsEstimated
|
||||
LastRefreshed = this.LastRefreshed
|
||||
}
|
||||
|
||||
/// The PureGym REST API. You probably want to instantiate one of these with `Api.make`.
|
||||
[<Header("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0")>]
|
||||
type IPureGymApi =
|
||||
@@ -247,7 +278,10 @@ type IPureGymApi =
|
||||
|
||||
/// Get information about the activities logged against the currently authenticated PureGym human.
|
||||
[<Get "v1/member/activity">]
|
||||
abstract GetMemberActivity : unit -> Task<MemberActivity>
|
||||
abstract GetMemberActivity : unit -> Task<MemberActivityDto>
|
||||
|
||||
// [<Get "v1/member/activity/history">]
|
||||
// abstract GetMemberActivityAll : unit -> Task<string>
|
||||
|
||||
/// Methods for interacting with the PureGym REST API.
|
||||
[<RequireQualifiedAccess>]
|
||||
|
Reference in New Issue
Block a user