From ad84e8fd96138522549f1293873cd33bdd7bccbe Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Tue, 15 Aug 2017 16:31:46 +0200 Subject: [PATCH 01/37] Started with a visualisation script, generating graphs with chart.js --- visualisation.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 visualisation.py diff --git a/visualisation.py b/visualisation.py new file mode 100644 index 0000000..05d17b7 --- /dev/null +++ b/visualisation.py @@ -0,0 +1,35 @@ +import argparse +import json +import os +import sys + + +def parse_files(directory, target_directory): + for filename in os.listdir(directory): + if filename.endswith("_summary.json"): + # parse summary, create graph + continue + elif filename.endswith(".json"): + # parse wellness data + continue + else: + continue + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description = 'Garmin Data Scraper', + epilog = 'Because the hell with APIs!', add_help = 'How to use', + prog = 'python download.py [-u | -c ] [ -s -e -d ] -o ') + parser.add_argument('-i', '--input', required = False, + help = 'Input directory.', default = os.path.join(os.getcwd(), 'Wellness/')) + parser.add_argument('-o', '--output', required = False, + help = 'Output directory.', default = os.path.join(os.getcwd(), 'Graphs/')) + args = vars(parser.parse_args()) + + # Sanity check, before we do anything: + if args['input'] is None and args['output'] is None: + print("Must specify an input (-i) directory for the Wellness data, and an output (-o) directory for graphs.") + sys.exit() + + # Try to use the user argument from command line + output = args['output'] From b99e726c27b5d5d684f91efa37206d3507b08ded Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Wed, 16 Aug 2017 12:38:15 +0200 Subject: [PATCH 02/37] Generate data for the wellness summary graphs --- templates/index.html | 110 +++++++++++++++++++++++++++++++++++++++++++ visualisation.py | 102 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 templates/index.html diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..c195a69 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,110 @@ + + + + Garmin Wellness + + + + + + +

Garmin Wellness

+ + {% for summary in summaries %} + +
+

{{ publication }}

+ + + + + + + {% if trends[publication]['average'] == 0.0: %} +

No new articles in at least {{ trends[publication]['nrdays'] }} days. Latest article is from {{ trends[publication]['latestarticle'] }}

+ {% else %} +

Trend: {{ '%0.2f'| format(trends[publication]['average']|float) }} average articles/day over the last {{ trends[publication]['nrdays'] }} days

+ {% endif %} + +
+ {% endfor %} + + + diff --git a/visualisation.py b/visualisation.py index 05d17b7..a8c827e 100644 --- a/visualisation.py +++ b/visualisation.py @@ -2,24 +2,105 @@ import json import os import sys +import jinja2 + + +def add_totalsteps_to_summary(content): + result = [] + totalsteps = 0 + for item in content: + totalsteps = totalsteps + item['steps'] + item['totalsteps'] = totalsteps + result.append(item) + return result + + +def summary_to_graphdata(content): + """Returns a list of datetime tuples with: + {'datetime': ["2017-08-12T22:00:00.0", ..], + 'totalsteps': [0, 0, 0, 10, 32, 42, 128, ..], + 'sleeping_steps': [0, 0, None, None, None, 0, None, ..], + 'active_steps': [None, None, 10, 500, 120242, None, ..], + 'sedentary_steps': [None + """ + datetimes = [] + totalsteps_list = [] + sleeping_steps_list = [] + active_steps_list = [] + sedentary_steps_list = [] + totalsteps = 0 + + for item in content: + sleeping_steps = 0 + active_steps = 0 + sedentary_steps = 0 + datetimes.append(item['startGMT']) + totalsteps = totalsteps + item['steps'] + totalsteps_list.append(totalsteps) + if item['primaryActivityLevel'] == 'sedentary': + sedentary_steps = item['steps'] + elif item['primaryActivityLevel'] == 'active': + active_steps = item['steps'] + elif item['primaryActivityLevel'] == 'sleeping': + sleeping_steps = item['steps'] + + sleeping_steps_list.append(sleeping_steps) + active_steps_list.append(active_steps) + sedentary_steps_list.append(sedentary_steps) + + return {'datetime': datetimes, 'totalsteps': totalsteps_list, + 'sleeping_steps': sleeping_steps_list, 'active_steps': active_steps_list, + 'sedentary_steps': sedentary_steps_list} + + +def parse_wellness(content): + return content def parse_files(directory, target_directory): - for filename in os.listdir(directory): + summary = [] + wellness = [] + for filename in sorted(os.listdir(directory)): + print filename if filename.endswith("_summary.json"): # parse summary, create graph - continue + with open(os.path.join(directory, filename), 'r') as f: + content = json.load(f) + summary.append(summary_to_graphdata(content)) elif filename.endswith(".json"): # parse wellness data continue else: continue + return summary, wellness + + + +def generate_wellnesspage(template_dir, outputfile, summary, wellness): + """ Generate graphs for the various measurements""" + loader = jinja2.FileSystemLoader(template_dir) + environment = jinja2.Environment(loader=loader, trim_blocks=True, lstrip_blocks=True) + + try: + template = environment.get_template('index.html') + except jinja2.exceptions.TemplateNotFound as e: + print 'E Template not found: ' + str(e) + ' in template dir ' + template_dir + sys.exit(2) + + data = {} + data['summaries'] = summary + data['wellness'] = wellness + + output = template.render(data) + with open(outputfile, 'w') as pf: + pf.write(output) + if __name__ == "__main__": - parser = argparse.ArgumentParser(description = 'Garmin Data Scraper', + parser = argparse.ArgumentParser(description = 'Garmin Data Visualiser', epilog = 'Because the hell with APIs!', add_help = 'How to use', - prog = 'python download.py [-u | -c ] [ -s -e -d ] -o ') + prog = 'python visualise.py -i -o ') parser.add_argument('-i', '--input', required = False, help = 'Input directory.', default = os.path.join(os.getcwd(), 'Wellness/')) parser.add_argument('-o', '--output', required = False, @@ -32,4 +113,15 @@ def parse_files(directory, target_directory): sys.exit() # Try to use the user argument from command line - output = args['output'] + outputdir = args['output'] + inputdir = args['input'] + summary, wellness = parse_files(inputdir, outputdir) + template_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates') + print template_dir + outputfile = os.path.join(outputdir, 'wellness.html') + + # Create output directory (if it does not already exist). + if not os.path.exists(outputdir): + os.makedirs(outputdir) + + #generate_wellnesspage(template_dir, outputfile, summary, wellness) From 2768bbc4a4b716679b005665e14cf44631a53b7e Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Aug 2017 09:25:14 +0200 Subject: [PATCH 03/37] Renamed to specific template --- templates/{index.html => wellness.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename templates/{index.html => wellness.html} (100%) diff --git a/templates/index.html b/templates/wellness.html similarity index 100% rename from templates/index.html rename to templates/wellness.html From c1520be1a3a585adc472699171594f6be9f33c6e Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Aug 2017 12:54:05 +0200 Subject: [PATCH 04/37] Generate coloured steps graphs --- templates/wellness.html | 77 +++++++++++++++++++++++++++-------------- visualisation.py | 13 ++++--- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index c195a69..61449f6 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -16,12 +16,12 @@ } .contentblock { - width: 500px; + width: 800px; float: left; padding: 5px; margin-bottom: 10px; margin-right: 10px; - background-color: #1f1d1d; +/* background-color: #1f1d1d;*/ border: 1px solid #292929; } .contentblock h2 @@ -49,59 +49,84 @@

Garmin Wellness

- {% for summary in summaries %} + {% for datestamp, summary in summaries %}
-

{{ publication }}

+

{{ datestamp }}

- + - {% if trends[publication]['average'] == 0.0: %} -

No new articles in at least {{ trends[publication]['nrdays'] }} days. Latest article is from {{ trends[publication]['latestarticle'] }}

- {% else %} -

Trend: {{ '%0.2f'| format(trends[publication]['average']|float) }} average articles/day over the last {{ trends[publication]['nrdays'] }} days

- {% endif %} +

Summary

{% endfor %} diff --git a/visualisation.py b/visualisation.py index a8c827e..0274b1f 100644 --- a/visualisation.py +++ b/visualisation.py @@ -27,12 +27,14 @@ def summary_to_graphdata(content): totalsteps_list = [] sleeping_steps_list = [] active_steps_list = [] + highlyactive_steps_list = [] sedentary_steps_list = [] totalsteps = 0 for item in content: sleeping_steps = 0 active_steps = 0 + highlyactive_steps = 0 sedentary_steps = 0 datetimes.append(item['startGMT']) totalsteps = totalsteps + item['steps'] @@ -41,16 +43,19 @@ def summary_to_graphdata(content): sedentary_steps = item['steps'] elif item['primaryActivityLevel'] == 'active': active_steps = item['steps'] + elif item['primaryActivityLevel'] == 'highlyActive': + highlyactive_steps = item['steps'] elif item['primaryActivityLevel'] == 'sleeping': sleeping_steps = item['steps'] sleeping_steps_list.append(sleeping_steps) active_steps_list.append(active_steps) + highlyactive_steps_list.append(highlyactive_steps) sedentary_steps_list.append(sedentary_steps) return {'datetime': datetimes, 'totalsteps': totalsteps_list, 'sleeping_steps': sleeping_steps_list, 'active_steps': active_steps_list, - 'sedentary_steps': sedentary_steps_list} + 'highlyactive_steps': highlyactive_steps_list, 'sedentary_steps': sedentary_steps_list} def parse_wellness(content): @@ -66,7 +71,7 @@ def parse_files(directory, target_directory): # parse summary, create graph with open(os.path.join(directory, filename), 'r') as f: content = json.load(f) - summary.append(summary_to_graphdata(content)) + summary.append((filename.split('_')[0], summary_to_graphdata(content))) elif filename.endswith(".json"): # parse wellness data continue @@ -83,7 +88,7 @@ def generate_wellnesspage(template_dir, outputfile, summary, wellness): environment = jinja2.Environment(loader=loader, trim_blocks=True, lstrip_blocks=True) try: - template = environment.get_template('index.html') + template = environment.get_template('wellness.html') except jinja2.exceptions.TemplateNotFound as e: print 'E Template not found: ' + str(e) + ' in template dir ' + template_dir sys.exit(2) @@ -124,4 +129,4 @@ def generate_wellnesspage(template_dir, outputfile, summary, wellness): if not os.path.exists(outputdir): os.makedirs(outputdir) - #generate_wellnesspage(template_dir, outputfile, summary, wellness) + generate_wellnesspage(template_dir, outputfile, summary, wellness) From 4d788ee5a683dec63630df551b0f1fcb730e237b Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Aug 2017 13:02:44 +0200 Subject: [PATCH 05/37] Also catch 'generic' and 'none' activity levels --- templates/wellness.html | 8 ++++++++ visualisation.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/templates/wellness.html b/templates/wellness.html index 61449f6..9042718 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -91,6 +91,14 @@

{{ datestamp }}

{% endfor %} ], backgroundColor: "rgba(153,255,51,0.4)" + }, { + label: 'various', + data: [ + {% for steps in summary['generic_steps'] %} + '{{ steps }}', + {% endfor %} + ], + backgroundColor: "rgba(153,153,153,0.4)" }, { label: 'sleeping', data: [ diff --git a/visualisation.py b/visualisation.py index 0274b1f..d8446b7 100644 --- a/visualisation.py +++ b/visualisation.py @@ -29,6 +29,7 @@ def summary_to_graphdata(content): active_steps_list = [] highlyactive_steps_list = [] sedentary_steps_list = [] + generic_steps_list = [] totalsteps = 0 for item in content: @@ -36,6 +37,7 @@ def summary_to_graphdata(content): active_steps = 0 highlyactive_steps = 0 sedentary_steps = 0 + generic_steps = 0 datetimes.append(item['startGMT']) totalsteps = totalsteps + item['steps'] totalsteps_list.append(totalsteps) @@ -47,15 +49,22 @@ def summary_to_graphdata(content): highlyactive_steps = item['steps'] elif item['primaryActivityLevel'] == 'sleeping': sleeping_steps = item['steps'] + elif item['primaryActivityLevel'] == 'generic' or item['primaryActivityLevel'] == 'none': + generic_steps = item['steps'] + else: + #print(item['primaryActivityLevel']) + print(item) sleeping_steps_list.append(sleeping_steps) active_steps_list.append(active_steps) highlyactive_steps_list.append(highlyactive_steps) sedentary_steps_list.append(sedentary_steps) + generic_steps_list.append(generic_steps) return {'datetime': datetimes, 'totalsteps': totalsteps_list, 'sleeping_steps': sleeping_steps_list, 'active_steps': active_steps_list, - 'highlyactive_steps': highlyactive_steps_list, 'sedentary_steps': sedentary_steps_list} + 'highlyactive_steps': highlyactive_steps_list, 'sedentary_steps': sedentary_steps_list, + 'generic_steps': generic_steps_list} def parse_wellness(content): From 0a410fa31593cf8a66dbbe3159156458d4ac016a Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Aug 2017 13:17:24 +0200 Subject: [PATCH 06/37] Reorder sleeping so it's at the beginning --- templates/wellness.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index 9042718..ea05d6e 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -68,6 +68,14 @@

{{ datestamp }}

{% endfor %} ], datasets: [{ + label: 'sleeping', + data: [ + {% for steps in summary['sleeping_steps'] %} + '{{ steps }}', + {% endfor %} + ], + backgroundColor: "rgba(0,0,153,0.4)" + }, { label: 'sedentary', data: [ {% for steps in summary['sedentary_steps'] %} @@ -99,14 +107,6 @@

{{ datestamp }}

{% endfor %} ], backgroundColor: "rgba(153,153,153,0.4)" - }, { - label: 'sleeping', - data: [ - {% for steps in summary['sleeping_steps'] %} - '{{ steps }}', - {% endfor %} - ], - backgroundColor: "rgba(0,0,153,0.4)" }, { label: 'totalsteps', data: [ From 657295c10f44ab762e2be1af336fa816f0ee7732 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Aug 2017 13:17:26 +0200 Subject: [PATCH 07/37] Reverse sort: latest day at top --- visualisation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/visualisation.py b/visualisation.py index d8446b7..9013709 100644 --- a/visualisation.py +++ b/visualisation.py @@ -87,8 +87,10 @@ def parse_files(directory, target_directory): else: continue - return summary, wellness + # Reverse list so latest days are on top + summary = summary[::-1] + return summary, wellness def generate_wellnesspage(template_dir, outputfile, summary, wellness): From ad38d309622ff6e9fbba1fa59d6275cb169a851e Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Aug 2017 15:31:58 +0200 Subject: [PATCH 08/37] Show steps and floors stats --- templates/wellness.html | 40 +++++++++++++++++++++++++++++++--------- visualisation.py | 29 +++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index ea05d6e..4ea418e 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -9,11 +9,17 @@ { background-color: #FFF; } -h1, p, .contentblock +h1, h2, p, .contentblock { font-family: Verdana, sans-serif; color: #141414; } +h2 +{ + color: #AAA; + border-bottom: 1px solid #AAA; + clear: both; +} .contentblock { width: 800px; @@ -21,8 +27,8 @@ padding: 5px; margin-bottom: 10px; margin-right: 10px; -/* background-color: #1f1d1d;*/ - border: 1px solid #292929; +/* background-color: #1f1d1d; + border: 1px solid #292929;*/ } .contentblock h2 { @@ -51,8 +57,8 @@

Garmin Wellness

{% for datestamp, summary in summaries %} -

{{ datestamp }}

+
@@ -114,7 +120,6 @@

{{ datestamp }}

'{{ steps }}', {% endfor %} ], - /*backgroundColor: "rgba(255,255,0,0.4)",*/ borderColor: "rgba(0,0,0,0.4)", type: 'line' }, @@ -126,16 +131,33 @@

{{ datestamp }}

] }, options: { - scales: { + scales: { xAxes: [{ - type: 'time', - }]} + type: 'time', + }] + }, + layout: { + padding: { + left: 50, + right: 0, + top: 0, + bottom: 0 + } + } } }); -

Summary

+
+
+

Summary

+
    +
  • Steps total: {{ wellness['total_steps'][datestamp] }}
  • +
  • Steps goal: {{ wellness['total_step_goal'][datestamp] }}
  • +
  • Floors ascended: {{ wellness['floors_ascended'][datestamp] }}
  • +
  • Floors descended: {{ wellness['floors_descended'][datestamp] }}
  • +
{% endfor %} diff --git a/visualisation.py b/visualisation.py index 9013709..60bcb97 100644 --- a/visualisation.py +++ b/visualisation.py @@ -53,6 +53,7 @@ def summary_to_graphdata(content): generic_steps = item['steps'] else: #print(item['primaryActivityLevel']) + print('Unknown activity level found:') print(item) sleeping_steps_list.append(sleeping_steps) @@ -67,23 +68,40 @@ def summary_to_graphdata(content): 'generic_steps': generic_steps_list} -def parse_wellness(content): - return content +def parse_wellness(wellness, content): + try: + content['allMetrics'] + except TypeError: + # Not a correct wellness file + return wellness + + for item in content['allMetrics']['metricsMap']: + key = item.lstrip('WELLNESS_').lower() + for value in content['allMetrics']['metricsMap'][item]: + if key not in wellness: + wellness[key] = {} + if value['value']: + wellness[key][value['calendarDate']] = int(value['value']) + else: + wellness[key][value['calendarDate']] = None + return wellness def parse_files(directory, target_directory): summary = [] - wellness = [] + wellness = {} for filename in sorted(os.listdir(directory)): - print filename if filename.endswith("_summary.json"): # parse summary, create graph with open(os.path.join(directory, filename), 'r') as f: content = json.load(f) summary.append((filename.split('_')[0], summary_to_graphdata(content))) elif filename.endswith(".json"): + print filename # parse wellness data - continue + with open(os.path.join(directory, filename), 'r') as f: + content = json.load(f) + wellness = parse_wellness(wellness, content) else: continue @@ -133,7 +151,6 @@ def generate_wellnesspage(template_dir, outputfile, summary, wellness): inputdir = args['input'] summary, wellness = parse_files(inputdir, outputdir) template_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates') - print template_dir outputfile = os.path.join(outputdir, 'wellness.html') # Create output directory (if it does not already exist). From 1fd24d90249c07541d18097224157dfed86a999c Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 19 Aug 2017 14:01:12 +0200 Subject: [PATCH 09/37] More stats, nice glyphs (Foundation webfont) --- templates/wellness.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index 4ea418e..b7ab9ea 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -4,6 +4,7 @@ Garmin Wellness + @@ -151,12 +160,13 @@

{{ datestamp }}

-

Summary

    -
  • Steps total: {{ wellness['total_steps'][datestamp] }}
  • -
  • Steps goal: {{ wellness['total_step_goal'][datestamp] }}
  • -
  • Floors ascended: {{ wellness['floors_ascended'][datestamp] }}
  • -
  • Floors descended: {{ wellness['floors_descended'][datestamp] }}
  • +
  • {{ wellness['total_steps'][datestamp] }} / {{ wellness['total_step_goal'][datestamp] }}
  • +
  • {{ wellness['floors_ascended'][datestamp] }} / {{ wellness['user_floors_ascended_goal'][datestamp] }} {{ wellness['floors_descended'][datestamp] }}
  • +
  • {{ wellness['bmr_calories'][datestamp] }}
  • + {% if wellness['vigorous_intensity_minutes'][datestamp] %} +
  • {{ wellness['vigorous_intensity_minutes'][datestamp] }} minutes
  • + {% endif %}
{% endfor %} From 19505e79138a2f8fd0d2f3f2fe5ad95d050b6848 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 19 Aug 2017 14:31:02 +0200 Subject: [PATCH 10/37] More stats --- templates/wellness.html | 21 +++++++++++++++++++-- visualisation.py | 6 +++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index b7ab9ea..f13af6d 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -21,6 +21,11 @@ border-bottom: 1px solid #AAA; clear: both; } +i +{ + width: 1.5em; + text-align: center; +} ul { list-style: none; @@ -161,12 +166,24 @@

{{ datestamp }}

    -
  • {{ wellness['total_steps'][datestamp] }} / {{ wellness['total_step_goal'][datestamp] }}
  • -
  • {{ wellness['floors_ascended'][datestamp] }} / {{ wellness['user_floors_ascended_goal'][datestamp] }} {{ wellness['floors_descended'][datestamp] }}
  • +
  • {{ wellness['total_steps'][datestamp] }} / {{ wellness['total_step_goal'][datestamp] }}
  • +
  • {{ wellness['total_distance'][datestamp] }}m
  • +
  • {{ wellness['floors_ascended'][datestamp] }} / {{ wellness['user_floors_ascended_goal'][datestamp] }} {{ wellness['floors_descended'][datestamp] }}
  • {{ wellness['bmr_calories'][datestamp] }}
  • {% if wellness['vigorous_intensity_minutes'][datestamp] %}
  • {{ wellness['vigorous_intensity_minutes'][datestamp] }} minutes
  • {% endif %} + {% if wellness['moderate_intensity_minutes'][datestamp] %} +
  • {{ wellness['moderate_intensity_minutes'][datestamp] }} minutes
  • + {% endif %} +
  • + {{ wellness['max_heart_rate'][datestamp] }} / + {{ wellness['min_heart_rate'][datestamp] }} / + {{ wellness['resting_heart_rate'][datestamp] }} +
  • + {% if wellness['sleep_duration'][datestamp] %} +
  • {{ wellness['sleep_duration'][datestamp] / 3600 }} hours
  • + {% endif %}
{% endfor %} diff --git a/visualisation.py b/visualisation.py index 60bcb97..6f0d9ba 100644 --- a/visualisation.py +++ b/visualisation.py @@ -76,7 +76,11 @@ def parse_wellness(wellness, content): return wellness for item in content['allMetrics']['metricsMap']: - key = item.lstrip('WELLNESS_').lower() + if 'SLEEP_' in item: + key = item[len('SLEEP_'):].lower() + else: + key = item.lstrip('WELLNESS_').lower() + print(key) for value in content['allMetrics']['metricsMap'][item]: if key not in wellness: wellness[key] = {} From ff28eea846b1a4980b9f2f34a8bc939bca3f4e5e Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sun, 20 Aug 2017 10:05:36 +0200 Subject: [PATCH 11/37] More Calories, disable animation, slight tweaks --- templates/wellness.html | 7 +++++-- visualisation.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index f13af6d..14c3358 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -157,6 +157,9 @@

{{ datestamp }}

top: 0, bottom: 0 } + }, + animation: { + duration: 0 } } }); @@ -169,20 +172,20 @@

{{ datestamp }}

  • {{ wellness['total_steps'][datestamp] }} / {{ wellness['total_step_goal'][datestamp] }}
  • {{ wellness['total_distance'][datestamp] }}m
  • {{ wellness['floors_ascended'][datestamp] }} / {{ wellness['user_floors_ascended_goal'][datestamp] }} {{ wellness['floors_descended'][datestamp] }}
  • -
  • {{ wellness['bmr_calories'][datestamp] }}
  • {% if wellness['vigorous_intensity_minutes'][datestamp] %}
  • {{ wellness['vigorous_intensity_minutes'][datestamp] }} minutes
  • {% endif %} {% if wellness['moderate_intensity_minutes'][datestamp] %}
  • {{ wellness['moderate_intensity_minutes'][datestamp] }} minutes
  • {% endif %} +
  • {{ wellness['total_calories'][datestamp] }} / {{ wellness['active_calories'][datestamp] }} / {{ wellness['bmr_calories'][datestamp] }}
  • {{ wellness['max_heart_rate'][datestamp] }} / {{ wellness['min_heart_rate'][datestamp] }} / {{ wellness['resting_heart_rate'][datestamp] }}
  • {% if wellness['sleep_duration'][datestamp] %} -
  • {{ wellness['sleep_duration'][datestamp] / 3600 }} hours
  • +
  • {{ (wellness['sleep_duration'][datestamp] / 3600) | round(1, 'common') }} hours
  • {% endif %} diff --git a/visualisation.py b/visualisation.py index 6f0d9ba..0faf9b4 100644 --- a/visualisation.py +++ b/visualisation.py @@ -80,7 +80,6 @@ def parse_wellness(wellness, content): key = item[len('SLEEP_'):].lower() else: key = item.lstrip('WELLNESS_').lower() - print(key) for value in content['allMetrics']['metricsMap'][item]: if key not in wellness: wellness[key] = {} From e243c186e173ef068c5d69ac26016edc20f87147 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sun, 20 Aug 2017 19:25:58 +0200 Subject: [PATCH 12/37] Brighter colours in the bars --- templates/wellness.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/wellness.html b/templates/wellness.html index 14c3358..dffaad8 100644 --- a/templates/wellness.html +++ b/templates/wellness.html @@ -8,7 +8,7 @@