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
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
......
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