Skip to content

Commit

Permalink
Merge pull request #1208 from thomaschampagne/bugfix/broken-sync
Browse files Browse the repository at this point in the history
Bugfix/broken sync
  • Loading branch information
thomaschampagne authored Nov 3, 2024
2 parents 3316006 + 9c397fc commit 8b4989d
Show file tree
Hide file tree
Showing 24 changed files with 189 additions and 386 deletions.
64 changes: 1 addition & 63 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,63 +1 @@
#!/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 "pre-commit" "$@"
npm run prettier
1 change: 0 additions & 1 deletion appcore/modules/shared/sync/compute/activity-computer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,6 @@ export class ActivityComputer {
)
: null;


// Efficiency
scores.efficiency =
stats?.power?.weighted && stats?.heartRate?.avg
Expand Down
4 changes: 2 additions & 2 deletions appcore/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion appcore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elevate-sports-app",
"version": "7.2.0",
"version": "7.2.1",
"license": "MPL-2.0",
"scripts": {
"ng": "ng",
Expand Down
4 changes: 2 additions & 2 deletions desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.2.0",
"version": "7.2.1",
"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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elevate-sports-app",
"version": "7.2.0",
"version": "7.2.1",
"description": "Wrap the needed tools required to cook Elevate desktop and web extension",
"maintainers": [
{
Expand Down Expand Up @@ -34,7 +34,7 @@
"wipe": "npm run clean && npm run wipe:package-locks && npm run wipe:node-modules",
"wipe:node-modules": "node ./node_modules/del-cli/cli.js ./node_modules/ ./appcore/node_modules/ ./desktop/node_modules/ ./webextension/node_modules/",
"wipe:package-locks": "node ./node_modules/del-cli/cli.js ./package-lock.json ./appcore/package-lock.json ./desktop/package-lock.json ./webextension/package-lock.json",
"prepare": "husky install"
"prepare": "husky"
},
"config": {
"unsafe-perm": true
Expand Down
4 changes: 2 additions & 2 deletions webextension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "Elevate for Strava",
"short_name": "Elevate",
"description": "Elevate your strava experience and goals! Track your fitness and progressions over time. Analyse deeper your activities. And more...",
"version": "7.2.0",
"version_name": "7.2.0",
"version": "7.2.1",
"version_name": "7.2.1",
"background": {
"service_worker": "extension/service_worker.bundle.js",
"type": "module"
Expand Down
4 changes: 2 additions & 2 deletions webextension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webextension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elevate-sports-app",
"version": "7.2.0",
"version": "7.2.1",
"description": "Chrome based extension adding features for Strava website with new performances data and improved ergonomics.",
"maintainers": [
{
Expand Down
23 changes: 13 additions & 10 deletions webextension/scripts/models/sync/strava-activity.model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export class StravaActivityModel {
public id: number;
public name: string;
public type: string;
public sport_type: string;
public display_type: string;
public activity_type_display_name: string;
public private: boolean;
public bike_id: number;
public athlete_gear_id: number;
public bike_id: number | null;
public athlete_gear_id: number | null;
public start_date: string;
public start_date_local_raw: number;
public start_time: string;
Expand All @@ -20,21 +20,24 @@ export class StravaActivityModel {
public elapsed_time: string;
public elapsed_time_raw: number;
public trainer: boolean;
public static_map: boolean;
public show_elevation: boolean;
public static_map: string;
public has_latlng: boolean;
public commute: boolean;
public elevation_gain: string;
public elevation_unit: string;
public elevation_gain_raw: number;
public description: string;
public description: string | null;
public activity_url: string;
public activity_url_for_twitter: string;
public twitter_msg: string;
public is_new: boolean;
public is_changing_type: boolean;
public suffer_score: number;
public calories: number;
public feed_data: any;
public workout_type: string;
public suffer_score: number | null;
public tags: { [key: string]: boolean };
public selected_tag_type: string | null;
public flagged: boolean;
public hide_power: boolean;
public hide_heartrate: boolean;
public leaderboard_opt_out: boolean;
public visibility: string;
}
4 changes: 2 additions & 2 deletions webextension/scripts/processors/activities-synchronize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ export class ActivitiesSynchronize {
if (foundActivity) {
// Yes => Check for an edit..

if (foundActivity.name !== rawActivity.name || foundActivity.type !== rawActivity.type) {
if (foundActivity.name !== rawActivity.name || foundActivity.type !== rawActivity.sport_type) {
edited.push({
id: foundActivity.id as number,
name: rawActivity.name,
type: rawActivity.type as ElevateSport
type: rawActivity.sport_type as ElevateSport
});
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class MultipleActivityProcessor {
const activityComputed: Activity = new Activity();
activityComputed.id = streamActivityModel.id;
activityComputed.name = streamActivityModel.name;
activityComputed.type = streamActivityModel.type as ElevateSport;
activityComputed.type = streamActivityModel.sport_type as ElevateSport;
activityComputed.startTimestamp = startTimestamp;
activityComputed.endTimestamp = endTimestamp;
activityComputed.startTime = streamActivityModel.start_time;
Expand All @@ -107,7 +107,7 @@ export class MultipleActivityProcessor {
activityComputed.stats.elapsedTime = streamActivityModel.elapsed_time_raw;
activityComputed.stats.distance = streamActivityModel.distance_raw;
activityComputed.stats.moveRatio = activityComputed.stats.movingTime / activityComputed.stats.elapsedTime;
activityComputed.stats.calories = streamActivityModel.calories;
// activityComputed.stats.calories = streamActivityModel.calories;
activityComputed.stats.caloriesPerHour =
activityComputed.stats.calories !== null
? (activityComputed.stats.calories / activityComputed.stats.elapsedTime) * Constant.SEC_HOUR_FACTOR
Expand Down Expand Up @@ -194,8 +194,8 @@ export class MultipleActivityProcessor {
const activityEssentials: ActivityEssentials = this.provideActivityEssentials(activityWithStream);

const threadMessage: ComputeActivityThreadMessageModel = {
activityType: activityWithStream.type as ElevateSport,
supportsGap: activityWithStream.type === "Run",
activityType: activityWithStream.sport_type as ElevateSport,
supportsGap: activityWithStream.sport_type === "Run",
isTrainer: activityWithStream.trainer,
appResources: this.appResources,
userSettings: this.userSettings,
Expand Down
Loading

0 comments on commit 8b4989d

Please sign in to comment.