Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zoneOffset to ExerciseSessionRecord results #126

Merged
merged 3 commits into from
Aug 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add startZoneOffset and endZoneOffset to ExerciseSessionRecord
  • Loading branch information
Minishlink committed Aug 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 695d86372e1e880184db71e0198d7df2990baa20
matinzd marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -74,6 +74,21 @@ class ReactExerciseSessionRecord : ReactHealthRecordImpl<ExerciseSessionRecord>
putString("notes", record.notes)
putString("title", record.title)
putInt("exerciseType", record.exerciseType)

if (record.startZoneOffset != null) {
putMap("startZoneOffset", WritableNativeMap().apply {
putString("id", record.startZoneOffset!!.id)
putInt("totalSeconds", record.startZoneOffset!!.totalSeconds)
})
Minishlink marked this conversation as resolved.
Show resolved Hide resolved
}

if (record.endZoneOffset != null) {
putMap("endZoneOffset", WritableNativeMap().apply {
putString("id", record.endZoneOffset!!.id)
putInt("totalSeconds", record.endZoneOffset!!.totalSeconds)
})
}

putArray("laps", WritableNativeArray().apply {
record.laps.map {
val map = WritableNativeMap()
5 changes: 5 additions & 0 deletions src/types/base.types.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@ export interface BaseRecord {
metadata?: Metadata;
}

export interface ZoneOffset {
id: string;
totalSeconds: number;
}

export interface InstantaneousRecord extends BaseRecord {
time: string;
}
3 changes: 3 additions & 0 deletions src/types/records.types.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import type {
ExerciseLap,
SleepStage,
ExerciseRoute,
ZoneOffset,
} from './base.types';

export interface ActiveCaloriesBurnedRecord extends IntervalRecord {
@@ -100,6 +101,8 @@ export interface ElevationGainedRecord extends IntervalRecord {
}

export interface ExerciseSessionRecord extends IntervalRecord {
startZoneOffset?: ZoneOffset;
endZoneOffset?: ZoneOffset;
recordType: 'ExerciseSession';
// Use ExerciseType constant
exerciseType: number;