Skip to content

Commit

Permalink
Merge branch 'release/7.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaschampagne committed Aug 11, 2024
2 parents 96c30ec + 058a12a commit dd77acf
Show file tree
Hide file tree
Showing 23 changed files with 449 additions and 48 deletions.
63 changes: 61 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook.exe -h >/dev/null 2>&1
then
lefthook.exe "$@"
elif lefthook.bat -h >/dev/null 2>&1
then
lefthook.bat "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

call_lefthook run "pre-commit" "$@"
63 changes: 63 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook.exe -h >/dev/null 2>&1
then
lefthook.exe "$@"
elif lefthook.bat -h >/dev/null 2>&1
then
lefthook.bat "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

call_lefthook run "prepare-commit-msg" "$@"
1 change: 1 addition & 0 deletions appcore/modules/shared/models/sync/activity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class TrainingEffect {

export class Scores {
public stress: StressScores;
public efficiency?: number;
public powerHr?: number;
public runningRating?: number;
public swolf?: { 25?: number; 50?: number };
Expand Down
7 changes: 7 additions & 0 deletions appcore/modules/shared/sync/compute/activity-computer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,13 @@ export class ActivityComputer {
)
: null;


// Efficiency
scores.efficiency =
stats?.power?.weighted && stats?.heartRate?.avg
? _.round(stats?.power?.weighted / stats?.heartRate?.avg, ActivityComputer.RND)
: null;

// Power/HR
scores.powerHr =
stats?.power?.avg && stats?.heartRate?.avg
Expand Down
4 changes: 2 additions & 2 deletions appcore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elevate-sports-app",
"version": "7.1.0",
"version": "7.2.0",
"license": "MPL-2.0",
"scripts": {
"ng": "ng",
Expand Down Expand Up @@ -106,4 +106,4 @@
"ts-node": "^10.7.0",
"typescript": "~4.8.4"
}
}
}
10 changes: 10 additions & 0 deletions appcore/src/app/activities/activity-columns.namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,16 @@ export namespace ActivityColumns {
Print.number,
1
).setDescription('"Running Rating" is an equivalent of "Running Index" from Polar'),
new NumberColumn(
Category.COMMON,
["stats", "scores", "efficiency"],
null,
"Efficiency Factor",
Print.number,
2
).setDescription(
'Efficiency Factor (EF) is your "Normalized Power® (Input)/ Average Heart rate (Output)". Higher value means better aerobic fit.'
),
new NumberColumn(
Category.COMMON,
["stats", "scores", "powerHr"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export abstract class EssentialStatsGroup extends StatsGroup {
StatsDef.Generic.movingTime,
StatsDef.Generic.elapsedTime,
StatsDef.Generic.moveRatio,
StatsDef.Scores.efficiency,
StatsDef.Scores.powerHr,
StatsDef.Generic.calories,
StatsDef.Generic.caloriesPerHour,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class CyclingPowerStatsGroup extends PowerStatsGroup {
StatsDef.Power.threshold(cyclingPowerSensor),
StatsDef.Scores.Stress.Cycling.pss(cyclingPowerSensor, activity.startTime),
StatsDef.Scores.Stress.Cycling.pssPerHour(cyclingPowerSensor, activity.startTime),
StatsDef.Power.variabilityIndex(cyclingPowerSensor),
StatsDef.Power.Cycling.intensity(cyclingPowerSensor, activity.startTime),
StatsDef.Power.variabilityIndex(cyclingPowerSensor),
StatsDef.Power.q25(cyclingPowerSensor),
StatsDef.Power.q50(cyclingPowerSensor),
StatsDef.Power.q75(cyclingPowerSensor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,14 @@ export namespace StatsDef {
}

export namespace Scores {
export const efficiency = Stat.create<Scores>(
VoidSensor.DEFAULT,
"Efficiency Factor",
["stats", "scores", "efficiency"],
'Efficiency Factor is your "Normalized Power® / Average Heart rate" ("Input Power / Output HR"). Higher value means better aerobic fit.',
2
).asEmptyUnit();

export const powerHr = Stat.create<Scores>(
VoidSensor.DEFAULT,
"Power/Hr",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { DesktopMigration } from "./desktop-migrations.model";
import { Upgrade_7_0_0$beta_3 } from "./upgrade_7_0_0-beta.3/upgrade_7_0_0-beta.3";
import { Upgrade_7_0_0$beta_5 } from "./upgrade_7_0_0-beta.5/upgrade_7_0_0-beta.5";
import { Upgrade_7_2_0 } from "./upgrade_7_2_0/upgrade_7_2_0";

/**
* Add desktop migrations inside LIST. The LIST is sorted from lowest to high versions
*/
export class DesktopRegisteredMigrations {
public static readonly LIST: DesktopMigration[] = [
new Upgrade_7_0_0$beta_3(), // To version 7.0.0-beta.3
new Upgrade_7_0_0$beta_5() // To version 7.0.0-beta.5
new Upgrade_7_0_0$beta_5(), // To version 7.0.0-beta.5
new Upgrade_7_2_0() // To version 7.2.0
/* Next Upgrade Here */
];
}
14 changes: 14 additions & 0 deletions appcore/src/app/desktop/migration/upgrade_7_2_0/upgrade_7_2_0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DesktopMigration } from "../desktop-migrations.model";
import { Injector } from "@angular/core";

export class Upgrade_7_2_0 extends DesktopMigration {
public version: string = "7.2.0";

public description: string = "Trigger recalculation for efficiency new stats & settings lacks detection fix";

public requiresRecalculation: boolean = true;

public upgrade(db: LokiConstructor, injector: Injector): Promise<void> {
return Promise.resolve();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ExtensionVersionsProvider extends VersionsProvider {
}

public getBuildMetadata(): Promise<{ commit: string; date: string }> {
const buildMetadata = require("../../../../../../../desktop/build_metadata.json");
const buildMetadata = require("../../../../../../../webextension/build_metadata.json");
return Promise.resolve(buildMetadata);
}

Expand Down
4 changes: 4 additions & 0 deletions appcore/src/assets/option-helpers/displayAdvancedPowerData.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ That's simply your _Average Power_ over your weight.

That's simply your _Normalized Power®_ over your weight.

# Efficiency Factor (EF)
---
Efficiency Factor (EF) is your "Normalized Power® (Input)/ Average Heart rate (Output)". Higher value means better aerobic fit.

# Quartiles and median
---

Expand Down
2 changes: 1 addition & 1 deletion appcore/src/environments/environment.desktop.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const environment = {
showActivityDebugData: false,
showRouteUrl: false,
bypassProfileRestoreChecks: false,
backendBaseUrl: "https://api.elevate.cloudns.ch"
backendBaseUrl: "https://api.elevate-app.duckdns.org"
};
2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elevate-sports-app",
"description": "Elevate your training experience and goals! Track your fitness and progressions over time. Analyse deeper your activities. And more...",
"version": "7.1.0",
"version": "7.2.0",
"scripts": {
"assert-app-exists": "node -e \"if ((require('fs').existsSync('./dist/app/')) === false) {console.log('Please run & wait for \\'npm start\\' task before.\\n\\n\\n\\n');process.exit(1);}\";",
"build:metadata": "node -e \"require('fs').writeFileSync('build_metadata.json', JSON.stringify({commit: require('child_process').execSync('git rev-parse HEAD').toString().trim(), date: new Date().toISOString()}));\"",
Expand Down
10 changes: 10 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# EXAMPLE USAGE:
#
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#
pre-commit:
parallel: true
commands:
lint:
run: npx --no-install pretty-quick --staged
Loading

0 comments on commit dd77acf

Please sign in to comment.