mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-09 17:09:45 +08:00
Add reset_export_projects_counter rake task
This commit is contained in:
parent
2d09e6fb6f
commit
e636f61d13
1 changed files with 18 additions and 0 deletions
|
@ -6,4 +6,22 @@ namespace :exportable_items do
|
||||||
puts "All exportable zip files older than " \
|
puts "All exportable zip files older than " \
|
||||||
"'#{num.days.ago}' have been removed"
|
"'#{num.days.ago}' have been removed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Resets export project counter to 0'
|
||||||
|
task reset_export_projects_counter: :environment do
|
||||||
|
User.all.each do |user|
|
||||||
|
User.transaction do
|
||||||
|
begin
|
||||||
|
user.export_vars['num_of_export_all_last_24_hours'] = 0
|
||||||
|
user.save
|
||||||
|
rescue ActiveRecord::ActiveRecordError,
|
||||||
|
ArgumentError,
|
||||||
|
ActiveRecord::RecordNotSaved => e
|
||||||
|
puts "Error creating user, transaction reverted: #{e}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
puts 'Export project counter successfully ' \
|
||||||
|
'reset on all users'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue