Skip to content
Snippets Groups Projects
Commit 32314dec authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira
Browse files

Merge branch 'issue/52-update-high_streak-function' into 'develop'

ISSUE #52: UPDATE high_streak function

See merge request rfhf19/cleanning-portalmec!49
parents d4b544bf 3a5eeaf9
No related branches found
No related tags found
1 merge request!49ISSUE #52: UPDATE high_streak function
Pipeline #34739 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