- Timestamp:
- Apr 22, 2019, 6:14:53 PM (5 years ago)
- Branches:
- current
- Children:
- 0dedfbe
- Parents:
- e52a502
- Location:
- ow/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/models/root.py
re52a502 r42baca4 43 43 'nickname': CatalogFieldIndex('nickname'), 44 44 'sport': CatalogFieldIndex('sport'), 45 'hashed': CatalogFieldIndex('hashed'), 45 46 } 46 47 return indexes … … 140 141 def sports_json(self): 141 142 return json.dumps(self.sports) 143 144 def get_workout_by_hash(self, hashed): 145 if hashed is not None: 146 # for some reason, when searching for None 147 # the catalog will return all workouts 148 res = self.query(Eq('hashed', hashed)) 149 if res: 150 return next(res) 151 return None -
ow/models/workout.py
re52a502 r42baca4 136 136 137 137 @property 138 def hashed(self): 139 """ 140 Return a unique hash that we use to look for duplicated workouts. 141 The hash contains: owner's uid, start time, duration and distance 142 """ 143 hashed = '' 144 if self.owner is not None: 145 hashed += str(self.owner.uid) 146 hashed += self.start.strftime('%Y%m%d%H%M%S') 147 hashed += str(self.duration.seconds) 148 hashed += str(self.distance) 149 return hashed 150 151 @property 138 152 def trimmed_notes(self): 139 153 """
Note: See TracChangeset
for help on using the changeset viewer.