mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Add reset_export_projects_counter rake task
This commit is contained in:
parent
26df1e5a98
commit
1761d57b9d
1 changed files with 18 additions and 0 deletions
|
@ -6,4 +6,22 @@ namespace :exportable_items do
|
|||
puts "All exportable zip files older than " \
|
||||
"'#{num.days.ago}' have been removed"
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue