@@ -156,7 +156,7 @@ export default class OuraRing implements Integration {
156
156
( await pathExists ( join ( "." , "data" , category , "daily" ) ) ) &&
157
157
( await lstat ( join ( "." , "data" , category , "daily" ) ) ) . isDirectory ( )
158
158
) {
159
- for await ( const file of [ "top-categories.json" , "top-overview .json"] ) {
159
+ for await ( const file of [ "sessions .json" ] ) {
160
160
const years = ( await readdir ( join ( "." , "data" , category , "daily" ) ) ) . filter ( ( i ) => / ^ \d + $ / . test ( i ) ) ;
161
161
const yearData : { [ index : string ] : CategoryData } = { } ;
162
162
const weeklyData : {
@@ -195,13 +195,27 @@ export default class OuraRing implements Integration {
195
195
"duration" ,
196
196
"efficiency" ,
197
197
"light" ,
198
+ "score" ,
199
+ "score_activity_balance" ,
200
+ "score_hrv_balance" ,
201
+ "score_previous_day" ,
202
+ "score_previous_night" ,
203
+ "score_recovery_index" ,
204
+ "score_resting_hr" ,
205
+ "score_sleep_balance" ,
206
+ "score_temperature" ,
198
207
] . forEach ( ( dataType ) => {
199
208
if ( typeof record [ dataType ] === "number" ) {
200
209
dailySum [ dataType ] = dailySum [ dataType ] || 0 ;
201
210
dailySum [ dataType ] += record [ dataType ] ;
202
211
}
203
212
} ) ;
204
213
} ) ;
214
+ } else if ( typeof json === "object" ) {
215
+ if ( typeof ( json as any ) . weight === "number" ) {
216
+ dailySum . weight = dailySum . weight || 0 ;
217
+ dailySum . weight += ( json as any ) . weight ;
218
+ }
205
219
}
206
220
if ( Object . keys ( dailySum ) . length ) dailyData [ parseInt ( day ) ] = dailySum ;
207
221
Object . keys ( dailySum ) . forEach ( ( key ) => {
@@ -221,31 +235,28 @@ export default class OuraRing implements Integration {
221
235
222
236
if ( Object . keys ( dailyData ) . length )
223
237
await write (
224
- join ( "." , "data" , category , "summary" , file . replace ( ".json" , "" ) , "days" , year , `${ month } .json` ) ,
238
+ join ( "." , "data" , category , "summary" , "days" , year , `${ month } .json` ) ,
225
239
JSON . stringify ( dailyData , null , 2 )
226
240
) ;
227
241
if ( monthlySum ) monthlyData [ parseInt ( month ) ] = monthlySum ;
228
242
}
229
243
if ( Object . keys ( monthlyData ) . length )
230
244
await write (
231
- join ( "." , "data" , category , "summary" , file . replace ( ".json" , "" ) , "months" , `${ year } .json` ) ,
245
+ join ( "." , "data" , category , "summary" , "months" , `${ year } .json` ) ,
232
246
JSON . stringify ( monthlyData , null , 2 )
233
247
) ;
234
248
if ( yearlySum ) yearData [ parseInt ( year ) ] = yearlySum ;
235
249
}
236
250
if ( Object . keys ( yearData ) . length )
237
- await write (
238
- join ( "." , "data" , category , "summary" , file . replace ( ".json" , "" ) , "years.json" ) ,
239
- JSON . stringify ( yearData , null , 2 )
240
- ) ;
251
+ await write ( join ( "." , "data" , category , "summary" , "years.json" ) , JSON . stringify ( yearData , null , 2 ) ) ;
241
252
for await ( const year of Object . keys ( weeklyData ) ) {
242
253
for await ( const week of Object . keys ( weeklyData [ year ] ) ) {
243
254
if (
244
255
Object . keys ( weeklyData [ year ] [ week ] ) . length &&
245
256
Object . values ( weeklyData [ year ] [ week ] ) . reduce ( ( a , b ) => a + Object . keys ( b ) . length , 0 )
246
257
)
247
258
await write (
248
- join ( "." , "data" , category , "summary" , file . replace ( ".json" , "" ) , "weeks" , year , `${ week } .json` ) ,
259
+ join ( "." , "data" , category , "summary" , "weeks" , year , `${ week } .json` ) ,
249
260
JSON . stringify ( weeklyData [ year ] [ week ] , null , 2 )
250
261
) ;
251
262
}
0 commit comments