@richhaase/c2 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/report.ts +13 -5
package/package.json
CHANGED
package/src/commands/report.ts
CHANGED
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
buildWeekSummaries,
|
|
12
12
|
computeGoalProgress,
|
|
13
13
|
type GoalProgress,
|
|
14
|
+
mondayOf,
|
|
14
15
|
type WeekSummary,
|
|
16
|
+
workoutsInRange,
|
|
15
17
|
} from "../stats.ts";
|
|
16
18
|
import { readWorkouts } from "../storage.ts";
|
|
17
19
|
|
|
@@ -393,11 +395,12 @@ function buildHTML(
|
|
|
393
395
|
goal: GoalProgress,
|
|
394
396
|
summaries: WeekSummary[],
|
|
395
397
|
allWorkouts: Workout[],
|
|
398
|
+
windowedWorkouts: Workout[],
|
|
396
399
|
recentCount: number,
|
|
397
400
|
): string {
|
|
398
|
-
const sessions = sessionCount(
|
|
399
|
-
const avgPace = avgPaceForWorkouts(
|
|
400
|
-
const avgHR = avgHRForWorkouts(
|
|
401
|
+
const sessions = sessionCount(windowedWorkouts);
|
|
402
|
+
const avgPace = avgPaceForWorkouts(windowedWorkouts);
|
|
403
|
+
const avgHR = avgHRForWorkouts(windowedWorkouts);
|
|
401
404
|
const today = new Date();
|
|
402
405
|
|
|
403
406
|
return `<!DOCTYPE html>
|
|
@@ -681,8 +684,13 @@ export function registerReport(program: Command): void {
|
|
|
681
684
|
console.error("Error: --weeks must be a positive integer.");
|
|
682
685
|
process.exit(1);
|
|
683
686
|
}
|
|
684
|
-
const
|
|
685
|
-
const
|
|
687
|
+
const now = new Date();
|
|
688
|
+
const summaries = buildWeekSummaries(workouts, now, weeks);
|
|
689
|
+
const thisMonday = mondayOf(now);
|
|
690
|
+
const cutoff = new Date(thisMonday);
|
|
691
|
+
cutoff.setDate(cutoff.getDate() - (weeks - 1) * 7);
|
|
692
|
+
const windowedWorkouts = workoutsInRange(workouts, cutoff, now);
|
|
693
|
+
const html = buildHTML(goal, summaries, workouts, windowedWorkouts, 10);
|
|
686
694
|
|
|
687
695
|
let outPath: string;
|
|
688
696
|
if (opts.output) {
|