mirror of
https://github.com/zoffline/zwift-offline.git
synced 2025-12-12 15:49:40 -08:00
Update to Zwift 1.0.142533
This commit is contained in:
@@ -1,179 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MapSchedule>
|
||||
<appointments>
|
||||
<appointment map="WATOPIA" start="2017-10-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-10-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-10-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-10-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-10-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-10-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-10-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-10-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2017-10-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-10-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-10-29T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2017-11-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-11-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-11-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-11-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-11-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-11-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2017-11-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-11-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-11-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-11-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2017-12-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-12-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-12-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-12-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-12-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-12-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-12-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-12-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2017-12-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2017-12-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2017-12-29T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-01-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-01-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-01-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-01-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-01-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-01-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-01-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-01-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-01-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-01-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-02-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-02-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-02-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-02-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-02-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-02-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-02-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-02-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-02-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-02-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-02-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-03-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-03-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-03-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-03-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-03-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-03-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-03-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-03-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-03-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-03-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-04-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-04-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-04-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-04-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-04-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-04-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-04-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-04-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-04-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-04-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-04-29T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-05-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-05-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-05-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-05-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-05-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-05-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-05-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-05-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-05-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-05-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-06-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-06-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-06-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-06-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-06-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-06-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-06-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-06-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-06-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-06-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-06-29T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-07-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-07-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-07-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-07-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-07-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-07-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-07-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-07-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-07-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-07-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-08-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-08-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-08-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-08-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-08-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-08-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-08-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-08-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-08-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-08-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-08-29T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-09-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-09-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-09-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-09-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-09-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-09-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-09-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-09-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-09-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-09-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-10-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-10-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-10-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-10-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-10-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-10-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-10-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-10-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-10-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-10-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-10-29T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-11-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-11-05T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-11-08T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-11-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-11-15T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-11-16T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-11-17T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-11-18T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-11-26T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-11-28T00:01-04"/>
|
||||
|
||||
<appointment map="WATOPIA" start="2018-12-01T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-12-02T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-12-05T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-12-08T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-12-09T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-12-14T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-12-16T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-12-24T00:01-04"/>
|
||||
<appointment map="RICHMOND" start="2018-12-25T00:01-04"/>
|
||||
<appointment map="WATOPIA" start="2018-12-26T00:01-04"/>
|
||||
<appointment map="LONDON" start="2018-12-29T00:01-04"/>
|
||||
</appointments>
|
||||
<VERSION>1</VERSION>
|
||||
</MapSchedule>
|
||||
@@ -1 +1 @@
|
||||
<Zwift version="1.0.141681" sversion="1.85.0 (141681)" gbranch="rc/1.85.0" gcommit="deff664a1137ef8cf72f03f6c16599aa7b4c4c9b" GAME_URL="https://us-or-rly101.zwift.com" manifest="ZwiftMac_1.0.141681_57fb1e1e_manifest.xml" manifest_checksum="-1019938103" ver_cur_checksum="-1356498206"/>
|
||||
<Zwift version="1.0.142533" sversion="1.85.2 (142533)" gbranch="rc/1.85.2" gcommit="43c6a1d08803187bdf14fae277cf487fef67d46d" GAME_URL="https://us-or-rly101.zwift.com" manifest="ZwiftMac_1.0.142533_4af2b74e_manifest.xml" manifest_checksum="1630521314" ver_cur_checksum="239437998"/>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<Zwift version="1.0.141681" sversion="1.85.0 (141681)" gbranch="rc/1.85.0" gcommit="deff664a1137ef8cf72f03f6c16599aa7b4c4c9b" GAME_URL="https://us-or-rly101.zwift.com" manifest="Zwift_1.0.141681_57fb1e1e_manifest.xml" manifest_checksum="1392858147" ver_cur_checksum="-997085502"/>
|
||||
<Zwift version="1.0.142533" sversion="1.85.2 (142533)" gbranch="rc/1.85.2" gcommit="43c6a1d08803187bdf14fae277cf487fef67d46d" GAME_URL="https://us-or-rly101.zwift.com" manifest="Zwift_1.0.142533_4af2b74e_manifest.xml" manifest_checksum="-110821375" ver_cur_checksum="1786621800"/>
|
||||
|
||||
@@ -245,6 +245,7 @@
|
||||
657449117,
|
||||
690995707,
|
||||
708573979,
|
||||
728024758,
|
||||
776931720,
|
||||
805406818,
|
||||
853522319,
|
||||
@@ -764,6 +765,7 @@
|
||||
1533880694,
|
||||
1541349594,
|
||||
1561591671,
|
||||
1561604078,
|
||||
1566215999,
|
||||
1567544184,
|
||||
1576116423,
|
||||
@@ -798,9 +800,11 @@
|
||||
1653550906,
|
||||
1653888411,
|
||||
1665932906,
|
||||
1668644908,
|
||||
1676005799,
|
||||
1677202555,
|
||||
1697837945,
|
||||
1699319860,
|
||||
1701380341,
|
||||
1716914056,
|
||||
1718052948,
|
||||
@@ -829,6 +833,7 @@
|
||||
1824423139,
|
||||
1825919692,
|
||||
1827481335,
|
||||
1831691152,
|
||||
1832490174,
|
||||
1834190741,
|
||||
1842355135,
|
||||
@@ -1289,6 +1294,7 @@
|
||||
3715802624,
|
||||
3720531761,
|
||||
3727543886,
|
||||
3733288445,
|
||||
3738771064,
|
||||
3739190510,
|
||||
3743745974,
|
||||
@@ -1323,6 +1329,7 @@
|
||||
3840633700,
|
||||
3847642573,
|
||||
3858299788,
|
||||
3858307522,
|
||||
3858579217,
|
||||
3859182028,
|
||||
3860078904,
|
||||
@@ -1407,6 +1414,7 @@
|
||||
4099535182,
|
||||
4100199100,
|
||||
4102459937,
|
||||
4102986832,
|
||||
4107861598,
|
||||
4108702181,
|
||||
4109295337,
|
||||
@@ -1448,7 +1456,8 @@
|
||||
4272071449,
|
||||
4283549492,
|
||||
4283763318,
|
||||
4288197284
|
||||
4288197284,
|
||||
4292298859
|
||||
],
|
||||
"wheels": [
|
||||
[
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,6 +2,7 @@
|
||||
"variants": [
|
||||
{
|
||||
"name": "bikemodifiercalculator_params",
|
||||
"value": true,
|
||||
"values": {
|
||||
"fields": {
|
||||
"bUseDriveTrainEfficiency": {
|
||||
@@ -11,7 +12,7 @@
|
||||
"boolValue": false
|
||||
},
|
||||
"bUseSockCDA": {
|
||||
"boolValue": false
|
||||
"boolValue": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +39,9 @@
|
||||
},
|
||||
"is_fitness_score_visible": {
|
||||
"boolValue": true
|
||||
},
|
||||
"is_light_theme": {
|
||||
"boolValue": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -936,13 +940,16 @@
|
||||
"numberValue": 0.5
|
||||
},
|
||||
"manualSteeringExtraHardness": {
|
||||
"numberValue": 1.0
|
||||
"numberValue": 0.0
|
||||
},
|
||||
"maxDistanceForFavoringCorrectSideInCm": {
|
||||
"numberValue": 5.0
|
||||
},
|
||||
"pillDistanceScale": {
|
||||
"numberValue": 0.45
|
||||
},
|
||||
"pillHardness": {
|
||||
"numberValue": 0.65
|
||||
"numberValue": 0.45
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1088,7 +1095,13 @@
|
||||
{
|
||||
"name": "game_1_73_ui_scheduler",
|
||||
"value": true,
|
||||
"values": {}
|
||||
"values": {
|
||||
"fields": {
|
||||
"bGrantSpinWheelRewardEarly": {
|
||||
"boolValue": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "game_1_74_intersection_level_lock_override_by_route",
|
||||
@@ -1346,7 +1359,7 @@
|
||||
"varintValue": "1744036200"
|
||||
},
|
||||
"the_big_spin_2025_stage_2_start_date": {
|
||||
"varintValue": "1741662000"
|
||||
"varintValue": "0"
|
||||
},
|
||||
"the_big_spin_2025_stage_3_end_date": {
|
||||
"varintValue": "1744036200"
|
||||
@@ -1378,6 +1391,7 @@
|
||||
},
|
||||
{
|
||||
"name": "game_1_83_streaks_backend_migration",
|
||||
"value": true,
|
||||
"values": {
|
||||
"fields": {
|
||||
"ContinueToUpdatePlayerProfileWithStreaks": {
|
||||
@@ -1460,6 +1474,9 @@
|
||||
"LoggingRate": {
|
||||
"varintValue": "2243911942421128"
|
||||
},
|
||||
"factoryTourAnimationSpeedPercent": {
|
||||
"numberValue": 0.6
|
||||
},
|
||||
"wkg_cap_per_hour": {
|
||||
"numberValue": 4.0
|
||||
},
|
||||
@@ -1995,10 +2012,6 @@
|
||||
"value": true,
|
||||
"values": {}
|
||||
},
|
||||
{
|
||||
"name": "gfx_opengl3_1",
|
||||
"values": {}
|
||||
},
|
||||
{
|
||||
"name": "gfx_useemptyshadowmaps",
|
||||
"value": true,
|
||||
|
||||
@@ -195,6 +195,32 @@ message PlayerProfile {
|
||||
optional ActivityPrivacyType default_activity_privacy = 125;
|
||||
optional bool connected_to_runtastic = 126;
|
||||
repeated PropertyChange property_changes = 127;
|
||||
optional uint32 target_xp = 128;
|
||||
optional uint32 target_run_xp = 129;
|
||||
optional uint32 f130 = 130;
|
||||
optional uint32 cur_streak = 131;
|
||||
optional uint32 max_streak = 132;
|
||||
optional uint64 last_ride = 133;
|
||||
optional uint32 week_ride_count = 134;
|
||||
//optional uint32 cur_streak_distance = 135; // 135-140 no longer updated, replaced by 146-151?
|
||||
//optional uint32 max_streak_distance = 136;
|
||||
//optional uint32 cur_streak_elevation = 137;
|
||||
//optional uint32 max_streak_elevation = 138;
|
||||
//optional uint32 cur_streak_calories = 139;
|
||||
//optional uint32 max_streak_calories = 140;
|
||||
optional uint32 cur_streak_xp = 141;
|
||||
optional uint32 max_streak_xp = 142;
|
||||
optional uint32 cur_streak_drops = 143;
|
||||
optional uint32 max_streak_drops = 144;
|
||||
optional float cur_streak_distance = 146;
|
||||
optional float cur_streak_elevation = 147;
|
||||
optional float cur_streak_calories = 148;
|
||||
optional float max_streak_distance = 149;
|
||||
optional float max_streak_elevation = 150;
|
||||
optional float max_streak_calories = 151;
|
||||
optional uint32 f153 = 153;
|
||||
optional string public_id = 154;
|
||||
optional float power_units = 155; // factory tour challenge
|
||||
}
|
||||
|
||||
message PlayerProfiles {
|
||||
@@ -343,3 +369,15 @@ message PowerCurveAggregationMsg {
|
||||
map<string, BestEffortPointMsg> watts = 1;
|
||||
map<string, BestEffortPointMsg> watts_per_kg = 2;
|
||||
}
|
||||
|
||||
message Streaks {
|
||||
optional uint32 cur_streak = 1;
|
||||
optional uint32 cur_streak_distance = 2;
|
||||
optional uint32 cur_streak_elevation = 3;
|
||||
optional uint32 cur_streak_calories = 4;
|
||||
optional uint32 max_streak = 5;
|
||||
optional uint32 max_streak_distance = 6;
|
||||
optional uint32 max_streak_elevation = 7;
|
||||
optional uint32 max_streak_calories = 8;
|
||||
optional uint64 week_end = 9;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2414,6 +2414,8 @@ def api_profiles_activities_id(player_id, activity_id):
|
||||
save_fit(player_id, '%s - %s' % (activity_id, activity.fit_filename), activity.fit)
|
||||
if current_user.enable_ghosts:
|
||||
save_ghost(player_id, quote(activity.name, safe=' '))
|
||||
if activity.sport == profile_pb2.Sport.CYCLING and activity.distanceInMeters >= 2000:
|
||||
update_streaks(player_id, activity)
|
||||
# For using with upload_activity
|
||||
with open('%s/%s/last_activity.bin' % (STORAGE_DIR, player_id), 'wb') as f:
|
||||
f.write(stream)
|
||||
@@ -3733,6 +3735,54 @@ def api_player_profile_user_game_storage_attributes():
|
||||
return ret.SerializeToString(), 200
|
||||
|
||||
|
||||
def get_streaks(player_id):
|
||||
streaks = profile_pb2.Streaks()
|
||||
streaks_file = '%s/%s/streaks.bin' % (STORAGE_DIR, player_id)
|
||||
if os.path.isfile(streaks_file):
|
||||
with open(streaks_file, 'rb') as f:
|
||||
streaks.ParseFromString(f.read())
|
||||
else:
|
||||
profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, player_id)
|
||||
if os.path.isfile(profile_file):
|
||||
profile = profile_pb2.PlayerProfile()
|
||||
with open(profile_file, 'rb') as f:
|
||||
profile.ParseFromString(f.read())
|
||||
for field in ['cur_streak', 'cur_streak_distance', 'cur_streak_elevation', 'cur_streak_calories',
|
||||
'max_streak', 'max_streak_distance', 'max_streak_elevation', 'max_streak_calories']:
|
||||
setattr(streaks, field, int(getattr(profile, field)))
|
||||
streaks.week_end = int(get_week_range(datetime.datetime.fromtimestamp(profile.last_ride))[1].timestamp() * 1000)
|
||||
with open(streaks_file, 'wb') as f:
|
||||
f.write(streaks.SerializeToString())
|
||||
return streaks
|
||||
|
||||
def update_streaks(player_id, activity):
|
||||
streaks = get_streaks(player_id)
|
||||
start_date = stime_to_timestamp(activity.start_date) * 1000
|
||||
if start_date > streaks.week_end + 604800000:
|
||||
streaks.cur_streak = 1
|
||||
streaks.cur_streak_distance = 0
|
||||
streaks.cur_streak_elevation = 0
|
||||
streaks.cur_streak_calories = 0
|
||||
elif start_date > streaks.week_end:
|
||||
streaks.cur_streak += 1
|
||||
streaks.cur_streak_distance += int(activity.distanceInMeters)
|
||||
streaks.cur_streak_elevation += int(activity.total_elevation)
|
||||
streaks.cur_streak_calories += int(activity.calories)
|
||||
streaks.max_streak = max(streaks.cur_streak, streaks.max_streak)
|
||||
streaks.max_streak_distance = max(streaks.cur_streak_distance, streaks.max_streak_distance)
|
||||
streaks.max_streak_elevation = max(streaks.cur_streak_elevation, streaks.max_streak_elevation)
|
||||
streaks.max_streak_calories = max(streaks.cur_streak_calories, streaks.max_streak_calories)
|
||||
streaks.week_end = int(get_week_range(datetime.datetime.strptime(activity.start_date, '%Y-%m-%dT%H:%M:%S%z'))[1].timestamp() * 1000)
|
||||
with open('%s/%s/streaks.bin' % (STORAGE_DIR, player_id), 'wb') as f:
|
||||
f.write(streaks.SerializeToString())
|
||||
|
||||
@app.route('/api/fitness/streaks', methods=['GET'])
|
||||
@jwt_to_session_cookie
|
||||
@login_required
|
||||
def api_fitness_streaks():
|
||||
return get_streaks(current_user.player_id).SerializeToString(), 200
|
||||
|
||||
|
||||
@app.teardown_request
|
||||
def teardown_request(exception):
|
||||
db.session.close()
|
||||
|
||||
Reference in New Issue
Block a user