Compare commits
2 Commits
5c0a2b5886
...
219c080bf5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
219c080bf5 | ||
| a74e8b0cf1 |
@ -76,6 +76,34 @@ class Habit:
|
||||
datetime.strptime(rawTracking[2], "%Y-%m-%dT%H:%M:%S.%f")))
|
||||
return trackings
|
||||
|
||||
def getStreak(self):
|
||||
streak = 0
|
||||
trackings = []
|
||||
for rawTracking in get_habitTrackings_by_habit_id(self.id):
|
||||
trackings.append(HabitTrackings(datetime.strptime(rawTracking[2], "%Y-%m-%d")))
|
||||
|
||||
trackings.sort(reverse=True)
|
||||
if current_date == tracking[0]:
|
||||
streak += 1
|
||||
for habitdate in trackings[1:]:
|
||||
future_date = habitdate - relativedelta(day=1)
|
||||
if future_date - habitdate == 0-0-1:
|
||||
streak + 1
|
||||
|
||||
|
||||
future_date = habitdate - relativedelta(day=1)
|
||||
|
||||
for habitdate in trackings:
|
||||
current_date = date.today()
|
||||
if current_date == habitdate or current_date == habitdate - relativedelta(day=1):
|
||||
streak += 1
|
||||
|
||||
future_date = habitdate - relativedelta(day=1)
|
||||
|
||||
return streak
|
||||
|
||||
|
||||
|
||||
def fill_statistics(self):
|
||||
count = 0
|
||||
self.checked = False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user