Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Murrayw123 committed Nov 16, 2021
1 parent ffabdc2 commit 5d6c46f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Parsers/myfitnesspal_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parse(self):

day = self.__client.get_date(today.year, today.month, today.day)

if day.complete or is_end_of_day(today):
if day.complete or is_end_of_day(today) or True:
weight = float(list(self.__client.get_measurements("Weight").items())[0][1])
point = (
Point("Daily Summary")
Expand All @@ -47,4 +47,4 @@ def parse(self):
time=today_with_hours,
)
)
self.__db_writer(point)
self._db_writer(point)
2 changes: 1 addition & 1 deletion Parsers/parser_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Parser(metaclass=abc.ABCMeta):
def __init__(self, db_writer):
self.__db_writer = db_writer
self._db_writer = db_writer

@abc.abstractmethod
def parse(cls):
Expand Down
4 changes: 2 additions & 2 deletions Parsers/repcount_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def parse(self):
csv_reader = csv.reader(csv_file, delimiter=",")
next(csv_reader)
self._parse_rows(list(csv_reader))
dbx.files_delete_v2(f"./{REPCOUNT_CSV_FILE}")
dbx.files_delete_v2(f"/{REPCOUNT_CSV_FILE}")
except ApiError as e:
print(e)

Expand Down Expand Up @@ -102,4 +102,4 @@ def _parse_rows(self, rep_list):
return self.__write_points(points)

def __write_points(self, points):
self.__db_writer(points)
self._db_writer(points)
4 changes: 2 additions & 2 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dynaconf import settings


class Database:
class Database(object):
def __init__(self):
client = InfluxDBClient(
url=settings.INFLUXDB_URL,
Expand All @@ -16,4 +16,4 @@ def __init__(self):
self.__write_api = client.write_api(write_options=SYNCHRONOUS)

def write(self, points: Point or List[Point]):
self.__write_api.write(org=settings.INFLUXDB_ORG, bucket=settings.INFLUXDB_BUCKET, record=points)
self.__write_api.write(org=settings.INFLUXDB_ORG, bucket=settings.INFLUX_DB_BUCKET, record=points)
6 changes: 2 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import datetime
from collections import Callable

from apscheduler.schedulers.blocking import BlockingScheduler
from influxdb_client import Point
from dynaconf import settings

from database import Database
from dynaconf import settings


def create_parsers(db_write_fn):
return [p(db_writer=db_write_fn) for p in settings.PARSERS]


class TaskRunner:
class TaskRunner(object):
def __init__(self):
database = Database()
self.__parsers = create_parsers(db_write_fn=database.write)
Expand Down

0 comments on commit 5d6c46f

Please sign in to comment.