Skip to content

Commit 087441d

Browse files
Finish 7.0.0-beta.3
2 parents 2138daf + 8c24e97 commit 087441d

File tree

17 files changed

+76
-28
lines changed

17 files changed

+76
-28
lines changed

appcore/modules/shared/models/sync/activity.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export class GradeStats {
111111
public stdDev: number;
112112
public slopeTime: SlopeStats;
113113
public slopeSpeed: SlopeStats;
114+
public slopePace: SlopeStats;
114115
public slopeDistance: SlopeStats;
115116
public slopeCadence: SlopeStats;
116117
public slopeProfile: SlopeProfile;

appcore/modules/shared/sync/compute/activity-computer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,12 @@ export class ActivityComputer {
13861386
down: _.round(_.mean(slopeProfileSpeeds.down), ActivityComputer.RND)
13871387
};
13881388

1389+
const slopePace: SlopeStats = {
1390+
up: _.round(Movement.speedToPace(slopeSpeed.up)),
1391+
flat: _.round(Movement.speedToPace(slopeSpeed.flat)),
1392+
down: _.round(Movement.speedToPace(slopeSpeed.down))
1393+
};
1394+
13891395
const slopeCadence: SlopeStats = {
13901396
up: !_.isEmpty(slopeProfileCadences.up) ? _.round(_.mean(slopeProfileCadences.up), ActivityComputer.RND) : null,
13911397
flat: !_.isEmpty(slopeProfileCadences.flat)
@@ -1411,6 +1417,7 @@ export class ActivityComputer {
14111417
stdDev: _.round(standardDeviation, ActivityComputer.RND),
14121418
slopeTime: slopeTime,
14131419
slopeSpeed: slopeSpeed,
1420+
slopePace: slopePace,
14141421
slopeDistance: slopeDistance,
14151422
slopeCadence: slopeCadence,
14161423
slopeProfile: slopeProfile,

appcore/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

appcore/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elevate-sports-app",
3-
"version": "7.0.0-beta.2",
3+
"version": "7.0.0-beta.3",
44
"license": "MPL-2.0",
55
"scripts": {
66
"ng": "ng",

appcore/src/app/desktop/activity-view/shared/models/stats/stats-def.namespace.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,21 +798,21 @@ export namespace StatsDef {
798798
export const paceUp = Stat.create<GradeStats>(
799799
PaceSensor.DEFAULT,
800800
"Climbing Pace",
801-
["stats", "grade", "slopeSpeed", "up"],
801+
["stats", "grade", "slopePace", "up"],
802802
`Climbing pace over ${ActivityComputer.GRADE_CLIMBING_LIMIT}% grade`
803803
);
804804

805805
export const paceFlat = Stat.create<GradeStats>(
806806
PaceSensor.DEFAULT,
807807
"Flat Pace",
808-
["stats", "grade", "slopeSpeed", "flat"],
808+
["stats", "grade", "slopePace", "flat"],
809809
`Pace on flat between ${ActivityComputer.GRADE_DOWNHILL_LIMIT}% and ${ActivityComputer.GRADE_CLIMBING_LIMIT}% grade`
810810
);
811811

812812
export const paceDown = Stat.create<GradeStats>(
813813
PaceSensor.DEFAULT,
814814
"Downhill Pace",
815-
["stats", "grade", "slopeSpeed", "down"],
815+
["stats", "grade", "slopePace", "down"],
816816
`Pace in downhills under ${ActivityComputer.GRADE_DOWNHILL_LIMIT}% grade`
817817
);
818818

appcore/src/app/desktop/backup/desktop-backup.service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { BackupMetadata } from "@elevate/shared/models/backup/backup-metadata.in
1313
import { RestoreEvent } from "@elevate/shared/models/backup/restore-event.int";
1414
import { BackupChunk } from "@elevate/shared/models/backup/backup-chunk.int";
1515
import { Channel } from "@elevate/shared/electron/channels.enum";
16+
import { VersionsProvider } from "../../shared/services/versions/versions-provider";
17+
import { DesktopVersionsProvider } from "../../shared/services/versions/impl/desktop-versions-provider.service";
1618

1719
@Injectable()
1820
export class DesktopBackupService {
@@ -21,6 +23,7 @@ export class DesktopBackupService {
2123

2224
constructor(
2325
@Inject(IPC_TUNNEL_SERVICE) public readonly ipcTunnelService: IpcTunnelService,
26+
@Inject(VersionsProvider) public readonly versionsProvider: DesktopVersionsProvider,
2427
@Inject(LoggerService) protected readonly logger: LoggerService,
2528
@Inject(DataStore) public readonly desktopDataStore: DesktopDataStore<object>
2629
) {}
@@ -222,7 +225,9 @@ export class DesktopBackupService {
222225
restoreProgress$.complete();
223226
channelSubscription.unsubscribe();
224227
this.logger.info(`Restored in ${Math.round(Date.now() - restoreStartTime)}ms`);
225-
return Promise.resolve();
228+
229+
// Set "backup version" as existing version to apply required migrations between backup and current version installed
230+
return this.versionsProvider.setExistingVersion(metadata.version);
226231
});
227232
}
228233
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { DesktopMigration } from "./desktop-migrations.model";
2+
import { Upgrade_7_0_0$beta_3 } from "./upgrade_7_0_0-beta.3/upgrade_7_0_0-beta.3";
23

34
/**
45
* Add desktop migrations inside LIST. The LIST is sorted from lowest to high versions
56
*/
67
export class DesktopRegisteredMigrations {
78
public static readonly LIST: DesktopMigration[] = [
9+
new Upgrade_7_0_0$beta_3() // To version 7.0.0-beta.3
810
/* Next Upgrade Here */
911
];
1012
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { DesktopMigration } from "../desktop-migrations.model";
2+
import { Injector } from "@angular/core";
3+
import { Activity } from "@elevate/shared/models/sync/activity.model";
4+
import _ from "lodash";
5+
6+
export class Upgrade_7_0_0$beta_3 extends DesktopMigration {
7+
public version: string = "7.0.0-beta.3";
8+
9+
public description: string = "Fix avg/max speeds/paces on intervals when imported from Strava";
10+
11+
public requiresRecalculation: boolean = true;
12+
13+
public upgrade(db: LokiConstructor, injector: Injector): Promise<void> {
14+
const activitiesCollection = db.getCollection("activities");
15+
if (activitiesCollection) {
16+
const activitiesFromStrava = activitiesCollection.find({ connector: "STRAVA" });
17+
if (activitiesFromStrava?.length) {
18+
activitiesFromStrava.forEach((activity: Activity) => {
19+
if (activity.laps?.length) {
20+
activity.laps = activity.laps.map(lap => {
21+
lap.avgSpeed = lap.avgSpeed >= 0 ? _.round(lap.avgSpeed * 3.6, 3) : null;
22+
lap.avgPace = Number.isFinite(lap.avgSpeed) && lap.avgSpeed > 0 ? _.round(3600 / lap.avgSpeed) : null;
23+
24+
lap.maxSpeed = lap.maxSpeed >= 0 ? _.round(lap.maxSpeed * 3.6, 3) : null;
25+
lap.maxPace = Number.isFinite(lap.maxSpeed) && lap.maxSpeed > 0 ? _.round(3600 / lap.maxSpeed) : null;
26+
27+
return lap;
28+
});
29+
activitiesCollection.update(activity);
30+
}
31+
});
32+
}
33+
}
34+
return this.saveDatabase(db);
35+
}
36+
}

appcore/src/app/shared/services/app-service/desktop/desktop-app.service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ export class DesktopAppService extends AppService {
3535
if (requestedByVersion) {
3636
// Observe for recalculation done asked by an applied migration
3737
this.userSettingsService.fetch().then((userSettings: DesktopUserSettings) => {
38-
const snackRef = this.snackBar.open(
39-
"Last upgrade requires activities recalculation. Let it proceed.",
40-
"Ok"
41-
);
38+
const snackRef = this.snackBar.open("Activities recalculation required. Let it proceed...", "Ok");
4239
this.activityService.recalculateAll(userSettings).then(() => {
4340
this.desktopMigrationService.clearRequiredRecalculation();
4441
snackRef.dismiss();

desktop/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)