use single query to invalidate cache for all affected work packages

pull/7539/head
Markus Kahl 5 years ago
parent f0dabd2476
commit 7d88b3b0c7
  1. 10
      db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb

@ -45,7 +45,7 @@ class AddDerivedEstimatedHoursToWorkPackages < ActiveRecord::Migration[5.2]
create_customizable_journals last_id: last_id
create_attachable_journals last_id: last_id
work_packages.each(&:touch) # invalidate cache
touch_work_packages work_packages # to invalidate cache
end
##
@ -164,4 +164,12 @@ class AddDerivedEstimatedHoursToWorkPackages < ActiveRecord::Migration[5.2]
WHERE #{journals}.id > #{last_id} -- make sure to only create entries for the newly created journals
")
end
def touch_work_packages(work_packages)
where = work_packages.arel.where_sql
WorkPackage.connection.execute("
UPDATE work_packages SET updated_at = NOW(), lock_version = lock_version + 1 #{where}
")
end
end

Loading…
Cancel
Save