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

Merge branch 'issue/48-fix-restart_streaks-task' into 'develop'

ISSUE #48: FIX restart_streaks task

See merge request rfhf19/cleanning-portalmec!45
parents 9f9d2e1c eac4c546
No related branches found
No related tags found
1 merge request!45ISSUE #48: FIX restart_streaks task
Pipeline #34370 failed
...@@ -17,9 +17,8 @@ namespace :user do ...@@ -17,9 +17,8 @@ namespace :user do
end end
desc "Restart users' streak" desc "Restart users' streak"
task :restart_streaks => :environment do task :restart_streaks => :environment do
noStreakIds = User.where(streak: 0).pluck(:id) usersWithStreak = User.where(" streak > 0 ")
users = User.where.not(id: noStreakIds) usersWithStreak.each do |user|
users.each do |user|
days = (Date.today - user.last_action_at).to_i days = (Date.today - user.last_action_at).to_i
if days >= 2 if days >= 2
user.update_attribute(:streak, 0) user.update_attribute(:streak, 0)
......
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