Skip to content
Snippets Groups Projects
Commit 3a5eeaf9 authored by tmn21's avatar tmn21 :rocket:
Browse files

ISSUE #52: UPDATE high_streak function

parent d4b544bf
No related branches found
No related tags found
1 merge request!49ISSUE #52: UPDATE high_streak function
Pipeline #34716 failed
...@@ -388,6 +388,12 @@ class User < ApplicationRecord ...@@ -388,6 +388,12 @@ class User < ApplicationRecord
end end
end end
def update_high_streak()
if self.high_streak < self.streak
self.update(high_streak: streak)
end
end
def update_streak() def update_streak()
if self.last_action_at==Date.today if self.last_action_at==Date.today
return return
...@@ -397,9 +403,7 @@ class User < ApplicationRecord ...@@ -397,9 +403,7 @@ class User < ApplicationRecord
if self.last_action_at==Date.yesterday if self.last_action_at==Date.yesterday
self.update(last_action_at: Date.today) self.update(last_action_at: Date.today)
self.update(streak: streak+1) self.update(streak: streak+1)
if self.high_streak < self.streak update_high_streak
self.update(high_streak: streak)
end
return return
end end
...@@ -407,6 +411,7 @@ class User < ApplicationRecord ...@@ -407,6 +411,7 @@ class User < ApplicationRecord
if (Date.today - self.last_action_at).to_i >= 2 if (Date.today - self.last_action_at).to_i >= 2
self.update(last_action_at: Date.today) self.update(last_action_at: Date.today)
self.update(streak: 1) self.update(streak: 1)
update_high_streak
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment