Skip to content

Commit

Permalink
fix up fields update and order for running effeciency #98
Browse files Browse the repository at this point in the history
  • Loading branch information
roznet committed Mar 13, 2022
1 parent eacc76f commit 784ea72
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ConnectStats/sqlite/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Update Fields




build.py will update fields.db from:

- files in cache directory are cached translated fields in multiple languages
Expand All @@ -9,6 +12,7 @@ build.py will update fields.db from:




### Connect IQ Field

1. Same steps as above
Expand Down
25 changes: 19 additions & 6 deletions ConnectStats/sqlite/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# To rebuild db from legacy:
# ./build.py --init legacy -o out/fields.db build
#
# Regular Usage:
# Add field:
# edit edit/gc_fields_manual.xlsx
# edit edit/fields_order.xlsx
# rerun to update:
# ./build.py -v -b out/fields.db -i latest -o out/fields.json build edit/gc_fields_manual.xlsx edit/fields_order.xlsx
#
#
#
# To rebuild db adding changes for a file (example here edit/gc_fields_manual.xlsx)
# -v : verbose
Expand All @@ -32,6 +38,11 @@
# -o : save to fields.json
# ./build.py -v -b out/fields.db -i latest -o out/fields.json build edit/gc_fields_manual.xlsx
# then git diff will show what changed or use 'diff' as a command instead of 'build'
#
#
# To rebuild db from legacy:
# ./build.py --init legacy -o out/fields.db build
#

import sqlite3
import argparse
Expand Down Expand Up @@ -431,7 +442,7 @@ def add_category_and_order(self, info):
if no activityType or null applies to all
'''
rv = None
debug = (self.key == '__CalcLossElevation')
debug = (self.key == '__CalcRunningEffectiveness')

if debug:
print( f'add: {info}' )
Expand Down Expand Up @@ -766,7 +777,7 @@ def init_latest(self):
self.types.verbose = self.verbose
self.types.read_from_modern_json( 'download/activity_types_modern.json' )
if self.verbose:
print( 'read {}'.format( base ) )
print( 'init with latest {}'.format( base ) )
self.types.read_from_db(base)
self.fields = Fields(self.types)
self.fields.verbose = self.verbose
Expand Down Expand Up @@ -809,6 +820,8 @@ def init_empty(self):
self.categories.verbose = self.verbose

def cmd_build(self):
if self.verbose:
print( 'start build' )
for fn in self.args.files:
self.process_file( fn )

Expand Down Expand Up @@ -863,7 +876,7 @@ def load_from_json(self,jname):
def process_file(self,fn):
if os.path.exists( fn ):
if self.verbose:
print( 'read {}'.format( fn ) )
print( 'process {}'.format( fn ) )
if fn.endswith( '.db' ) :
self.load_db( fn )
elif fn.endswith( '.json' ):
Expand Down
Binary file modified ConnectStats/sqlite/edit/gc_fields_manual.xlsx
Binary file not shown.
Binary file modified ConnectStats/sqlite/out/fields.db
Binary file not shown.
15 changes: 15 additions & 0 deletions ConnectStats/sqlite/out/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,10 @@
{
"field": "__CalcRotationDevelopment"
},
{
"en": "Running Effectiveness",
"field": "__CalcRunningEffectiveness"
},
{
"field": "__CalcStrideLength"
},
Expand Down Expand Up @@ -2895,6 +2899,11 @@
"field": "__CalcRotationDevelopment",
"field_order": 20
},
{
"category": "running",
"field": "__CalcRunningEffectiveness",
"field_order": 5
},
{
"category": "run",
"field": "__CalcStrideLength",
Expand Down Expand Up @@ -3848,6 +3857,12 @@
"field": "__CalcBestRollingWeightedMeanSpeed",
"metric": "kph",
"statute": "mph"
},
{
"activity_type": "running",
"field": "__CalcRunningEffectiveness",
"metric": "dimensionless",
"statute": "dimensionless"
}
]
}
2 changes: 1 addition & 1 deletion ConnectStats/src/GCActivity+Fields.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ -(GCField*)fieldForKey:(NSString*)fieldkey{
@"WeightedMeanVerticalRatio",
@"WeightedMeanAirTemperature",
@"WeightedMeanLegSpringStiffness",
CALC_METABOLIC_EFFICIENCY,
CALC_RUNNING_EFFECTIVENESS,
],
GC_TYPE_CYCLING:@[
@"SumDistance",
Expand Down
2 changes: 1 addition & 1 deletion ConnectStats/src/GCField.m
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ -(NSComparisonResult)compare:(id)other{
@[CALC_ASCENT_SPEED, CALC_MAX_ASCENT_SPEED],
@[CALC_DESCENT_SPEED, CALC_MAX_DESCENT_SPEED],
@[CALC_VERTICAL_SPEED, CALC_ASCENT_SPEED, CALC_DESCENT_SPEED],
@[CALC_METABOLIC_EFFICIENCY, CALC_RUNNING_EFFECTIVENESS, CALC_EFFICIENCY_FACTOR],
@[ CALC_RUNNING_EFFECTIVENESS, CALC_METABOLIC_EFFICIENCY, CALC_EFFICIENCY_FACTOR],

];
RZRetain(_groups);
Expand Down

0 comments on commit 784ea72

Please sign in to comment.