Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Goetz committed Feb 22, 2020
1 parent 51309e0 commit 7c48472
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Fit
Submodule Fit updated from 351ad4 to 65cf16
28 changes: 14 additions & 14 deletions FitBitDB/fitbit_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,35 @@ def get_activity_mins_stats(cls, db, func, start_ts, end_ts):
if vigorous_activity_time:
intensity_time = Fit.conversions.add_time(intensity_time, vigorous_activity_time, 2)
stats = {
'intensity_time' : intensity_time,
'moderate_activity_time' : moderate_activity_time,
'vigorous_activity_time' : vigorous_activity_time,
'intensity_time': intensity_time,
'moderate_activity_time': moderate_activity_time,
'vigorous_activity_time': vigorous_activity_time,
}
return stats

@classmethod
def get_floors_stats(cls, db, func, start_ts, end_ts):
return {'floors' : func(db, cls.floors, start_ts, end_ts)}
return {'floors': func(db, cls.floors, start_ts, end_ts)}

@classmethod
def get_steps_stats(cls, db, func, start_ts, end_ts):
return {'steps' : func(db, cls.steps, start_ts, end_ts)}
return {'steps': func(db, cls.steps, start_ts, end_ts)}

@classmethod
def get_weight_stats(cls, db, start_ts, end_ts):
stats = {
'weight_avg' : cls.get_col_avg(db, cls.weight, start_ts, end_ts, True),
'weight_min' : cls.get_col_min(db, cls.weight, start_ts, end_ts, True),
'weight_max' : cls.get_col_max(db, cls.weight, start_ts, end_ts),
'weight_avg': cls.get_col_avg(db, cls.weight, start_ts, end_ts, True),
'weight_min': cls.get_col_min(db, cls.weight, start_ts, end_ts, True),
'weight_max': cls.get_col_max(db, cls.weight, start_ts, end_ts),
}
return stats

@classmethod
def get_sleep_stats(cls, db, start_ts, end_ts):
return {
'sleep_avg' : Fit.conversions.min_to_dt_time(cls.get_col_avg(db, cls.asleep_mins, start_ts, end_ts, True)),
'sleep_min' : Fit.conversions.min_to_dt_time(cls.get_col_min(db, cls.asleep_mins, start_ts, end_ts, True)),
'sleep_max' : Fit.conversions.min_to_dt_time(cls.get_col_max(db, cls.asleep_mins, start_ts, end_ts)),
'sleep_avg': Fit.conversions.min_to_dt_time(cls.get_col_avg(db, cls.asleep_mins, start_ts, end_ts, True)),
'sleep_min': Fit.conversions.min_to_dt_time(cls.get_col_min(db, cls.asleep_mins, start_ts, end_ts, True)),
'sleep_max': Fit.conversions.min_to_dt_time(cls.get_col_max(db, cls.asleep_mins, start_ts, end_ts)),
}

@classmethod
Expand All @@ -121,9 +121,9 @@ def get_calories_stats(cls, db, start_ts, end_ts):
else:
calories_avg = None
return {
'calories_avg' : calories_avg,
'calories_bmr_avg' : calories_bmr_avg,
'calories_active_avg' : calories_active_avg,
'calories_avg': calories_avg,
'calories_bmr_avg': calories_bmr_avg,
'calories_active_avg': calories_active_avg,
}

@classmethod
Expand Down
5 changes: 3 additions & 2 deletions GarminDB/monitoring_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__copyright__ = "Copyright Tom Goetz"
__license__ = "GPL"


import logging
import datetime
from sqlalchemy import Column, Integer, DateTime, Time, Float, Enum, FLOAT, UniqueConstraint, PrimaryKeyConstraint
Expand Down Expand Up @@ -233,8 +234,8 @@ def get_active_calories(cls, session, activity_type, start_ts, end_ts):
def get_stats(cls, session, func, start_ts, end_ts):
"""Return a dict of stats for table entries within the time span."""
return {
'steps' : func(session, cls.steps, start_ts, end_ts),
'calories_active_avg' : (
'steps': func(session, cls.steps, start_ts, end_ts),
'calories_active_avg': (
cls.get_active_calories(session, Fit.field_enums.ActivityType.running, start_ts, end_ts)
+ cls.get_active_calories(session, Fit.field_enums.ActivityType.cycling, start_ts, end_ts)
+ cls.get_active_calories(session, Fit.field_enums.ActivityType.walking, start_ts, end_ts)
Expand Down
1 change: 1 addition & 0 deletions MSHealthDB/mshealth_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def get_monthly_stats(cls, db, first_day_ts, last_day_ts):

@classmethod
def get_yearly_stats(cls, db, year):
"""Return a dictionary of aggregate statistics for the given year."""
first_day_ts = datetime.datetime(year, 1, 1)
last_day_ts = first_day_ts + datetime.timedelta(365)
stats = cls.get_activity_mins_stats(db, cls.get_col_sum, first_day_ts, last_day_ts)
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rebuild_act_db: clean_garmin_activities_dbs build_garmin_activities

# update the exisitng dbs by downloading data files for dates after the last in the dbs and update the dbs
update_dbs: update_garmin
update_dbs_bin: update_garmin_bin
update_copy_dbs: copy_garmin_latest

release: flake8 zip_packages
Expand Down Expand Up @@ -141,6 +142,9 @@ copy_garmin:
update_garmin:
$(TIME) $(PYTHON) garmin.py --all --download --import --analyze --latest

update_garmin_bin: $(DIST)/garmin
$(DIST)/garmin --all --download --import --analyze --latest

copy_garmin_latest:
$(TIME) $(PYTHON) garmin.py --all --copy --import --analyze --latest

Expand Down
2 changes: 1 addition & 1 deletion Tcx
Submodule Tcx updated from c31478 to 934f5f
5 changes: 3 additions & 2 deletions graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import sys
import argparse
import datetime
import enum

import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import enum
import dateutil.parser

import HealthDB
Expand Down Expand Up @@ -138,7 +139,7 @@ def __graph_over(cls, date, over_data_dicts, under_data_dict, title, xlabel, yla
axes.set_yticks([])
# then graph the data that appears on top
colors = [Colors.r.name, Colors.b.name]
for index, data in enumerate(over_data_dicts):
for index, _ in enumerate(over_data_dicts):
over_data_dict = over_data_dicts[index]
color = colors[index]
label = over_data_dict['label']
Expand Down
2 changes: 1 addition & 1 deletion utilities
2 changes: 1 addition & 1 deletion version_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

python_required = (3, 0, 0)
python_tested = (3, 7, 5)
version_info = (1, 5, 0)
version_info = (1, 6, 0)
prerelease = True


Expand Down

0 comments on commit 7c48472

Please sign in to comment.