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

ISSUE #46: CREATE task restart users' streak

parent 4c774bfd
No related branches found
No related tags found
No related merge requests found
Pipeline #34333 failed
...@@ -17,7 +17,9 @@ namespace :user do ...@@ -17,7 +17,9 @@ namespace :user do
end end
desc "Restart users' streak" desc "Restart users' streak"
task :restart_streaks => :environment do task :restart_streaks => :environment do
User.all.each do |user| noStreakIds = User.where(streak: 0).pluck(:id)
users = User.where.not(id: noStreakIds)
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.
Please register or to comment