diff --git a/app/models/user.rb b/app/models/user.rb index 3ddf3ba4ff0dafc77d663999e45286767ce66660..f01650244285960f9e5635aab7a35db1a2cd1d68 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -388,6 +388,12 @@ class User < ApplicationRecord end end + def update_high_streak() + if self.high_streak < self.streak + self.update(high_streak: streak) + end + end + def update_streak() if self.last_action_at==Date.today return @@ -397,9 +403,7 @@ class User < ApplicationRecord if self.last_action_at==Date.yesterday self.update(last_action_at: Date.today) self.update(streak: streak+1) - if self.high_streak < self.streak - self.update(high_streak: streak) - end + update_high_streak return end @@ -407,6 +411,7 @@ class User < ApplicationRecord if (Date.today - self.last_action_at).to_i >= 2 self.update(last_action_at: Date.today) self.update(streak: 1) + update_high_streak end end