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

ISSUE #48: FIX restart_streaks task

parent 9f9d2e1c
No related branches found
No related tags found
1 merge request!45ISSUE #48: FIX restart_streaks task
Pipeline #34369 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