From 0c0271e113b1beb9b07445b5d4ff853c4dc9fa89 Mon Sep 17 00:00:00 2001
From: "Butler, Alexis (UG - Computer Science)" <ab02259@surrey.ac.uk>
Date: Sun, 9 May 2021 21:03:04 +0100
Subject: [PATCH] Weird tracking bug

---
 app/controllers/habits_controller.rb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb
index bff9746..f05194d 100644
--- a/app/controllers/habits_controller.rb
+++ b/app/controllers/habits_controller.rb
@@ -85,8 +85,10 @@ class HabitsController < ApplicationController
         format.html { redirect_to :root, notice: 'You have already done that today. Come back tomorrow!'  }
       end
     end
-
-    if @habit.streak > @habit.max_streak || @habit.max_streak.nil?
+    if @habit.max_streak.nil?
+      @habit.max_streak = @habit.streak
+      @habit.save
+    elsif @habit.streak > @habit.max_streak
       @habit.max_streak = @habit.streak
       @habit.save
     end
-- 
GitLab