Skip to content

Commit

Permalink
Convert plugins to use local database sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
viiru- committed Feb 13, 2024
1 parent f7839d2 commit e1ecc99
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/garmin-fit/garmin-fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def inDatabase(self, activity):
#comparing date and start time (sport may have been changed in DB after import)
time = self.detailsFromTCX(activity)
try:
self.pytrainer_main.ddbb.session.query(Activity).filter(Activity.date_time_utc == time).one()
self.pytrainer_main.ddbb.sessionmaker().query(Activity).filter(Activity.date_time_utc == time).one()
return True
except exc.NoResultFound:
return False
Expand Down
2 changes: 1 addition & 1 deletion plugins/garmin-gpx/garmingpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def inDatabase(self, filename):
"""
time = self.detailsFromGPX(filename)
try:
self.pytrainer_main.ddbb.session.query(Activity).filter(Activity.date_time_utc == time).one()
self.pytrainer_main.ddbb.sessionmaker().query(Activity).filter(Activity.date_time_utc == time).one()
return True
except exc.NoResultFound:
return False
Expand Down
2 changes: 1 addition & 1 deletion plugins/garmin-hr-file/garminhrfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def shouldImport(self, track):
else:
time = timeElement.text
try:
self.pytrainer_main.ddbb.session.query(Activity).filter(Activity.date_time_utc == time).one()
self.pytrainer_main.ddbb.sessionmaker().query(Activity).filter(Activity.date_time_utc == time).one()
return False
except exc.NoResultFound:
return True
Expand Down
2 changes: 1 addition & 1 deletion plugins/garmin-hr/garminhr.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def shouldImport(self, track):
else:
time = timeElement.text
try:
self.pytrainer_main.ddbb.session.query(Activity).filter(Activity.date_time_utc == time).one()
self.pytrainer_main.ddbb.sessionmaker().query(Activity).filter(Activity.date_time_utc == time).one()
return False
except exc.NoResultFound:
return True
Expand Down
2 changes: 1 addition & 1 deletion plugins/garmin-tcxv2/garmin-tcxv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def inDatabase(self, activity):
#comparing date and start time (sport may have been changed in DB after import)
time = self.detailsFromTCX(activity)
try:
self.pytrainer_main.ddbb.session.query(Activity).filter(Activity.date_time_utc == time).one()
self.pytrainer_main.ddbb.sessionmaker().query(Activity).filter(Activity.date_time_utc == time).one()
return True
except exc.NoResultFound:
return False
Expand Down
2 changes: 1 addition & 1 deletion plugins/garmintools/garmintools.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def inDatabase(self, tree):
#comparing date and start time (sport may have been changed in DB after import)
time = self.detailsFromFile(tree)
try:
self.pytrainer_main.ddbb.session.query(Activity).filter(Activity.date_time_utc == time).one()
self.pytrainer_main.ddbb.sessionmaker().query(Activity).filter(Activity.date_time_utc == time).one()
return True
except exc.NoResultFound:
return False
Expand Down
2 changes: 1 addition & 1 deletion plugins/garmintools_full/garmintools_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def run(self):
if len(selectedFiles) > 0:
logging.info("Dumping "+str(len(selectedFiles))+" binary files found")
dumpFiles = self.dumpBinaries(selectedFiles)
self.listStringDBUTC = self.pytrainer_main.ddbb.session.query(Activity)
self.listStringDBUTC = self.pytrainer_main.ddbb.sessionmaker().query(Activity)
if self.maxGap > 0:
logging.info("Starting import. Comparison will be made with "+str(self.maxGap)+" seconds interval")
else:
Expand Down

0 comments on commit e1ecc99

Please sign in to comment.