From 349352773fe0e0c2762bc1123796a13c203349f1 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 12 Jun 2024 13:49:12 +0200 Subject: [PATCH 1/2] Revert - Fix activties for deleted results [SCI-10432] --- app/controllers/results_controller.rb | 2 +- app/models/my_module.rb | 1 - app/models/result.rb | 3 --- app/services/activities_service.rb | 17 +++-------------- ...0240429070135_add_discarded_at_to_results.rb | 6 ------ db/schema.rb | 4 +--- 6 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 db/migrate/20240429070135_add_discarded_at_to_results.rb diff --git a/app/controllers/results_controller.rb b/app/controllers/results_controller.rb index 0bb49c070..1a8301077 100644 --- a/app/controllers/results_controller.rb +++ b/app/controllers/results_controller.rb @@ -121,7 +121,7 @@ class ResultsController < ApplicationController def destroy name = @result.name - if @result.discard + if @result.destroy log_activity(:destroy_result, { destroyed_result: name }) render json: {}, status: :ok else diff --git a/app/models/my_module.rb b/app/models/my_module.rb index e1eea3c3a..efd7c4634 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -56,7 +56,6 @@ class MyModule < ApplicationRecord belongs_to :changing_from_my_module_status, optional: true, class_name: 'MyModuleStatus' delegate :my_module_status_flow, to: :my_module_status, allow_nil: true has_many :results, inverse_of: :my_module, dependent: :destroy - has_many :results_include_discarded, -> { with_discarded }, class_name: 'Result', inverse_of: :my_module has_many :my_module_tags, inverse_of: :my_module, dependent: :destroy has_many :tags, through: :my_module_tags, dependent: :destroy has_many :task_comments, foreign_key: :associated_id, dependent: :destroy diff --git a/app/models/result.rb b/app/models/result.rb index 767937497..caab15ba6 100644 --- a/app/models/result.rb +++ b/app/models/result.rb @@ -5,9 +5,6 @@ class Result < ApplicationRecord include SearchableModel include SearchableByNameModel include ViewableModel - include Discard::Model - - default_scope -> { kept } auto_strip_attributes :name, nullify: false validates :name, length: { maximum: Constants::NAME_MAX_LENGTH } diff --git a/app/services/activities_service.rb b/app/services/activities_service.rb index 634153b3f..c6020b70a 100644 --- a/app/services/activities_service.rb +++ b/app/services/activities_service.rb @@ -55,20 +55,9 @@ class ActivitiesService child_model = parent_model.reflect_on_association(child).class_name.to_sym next if subjects[child_model] - - if subject_name == 'Result' - parent_model = parent_model.with_discarded - end - - if child == :results - subjects[child_model] = parent_model.where(id: subjects[subject_name]) - .joins(:results_include_discarded) - .pluck('results.id') - else - subjects[child_model] = parent_model.where(id: subjects[subject_name]) - .joins(child) - .pluck("#{child.to_s.pluralize}.id") - end + subjects[child_model] = parent_model.where(id: subjects[subject_name]) + .joins(child) + .pluck("#{child.to_s.pluralize}.id") end end diff --git a/db/migrate/20240429070135_add_discarded_at_to_results.rb b/db/migrate/20240429070135_add_discarded_at_to_results.rb deleted file mode 100644 index 9df762e68..000000000 --- a/db/migrate/20240429070135_add_discarded_at_to_results.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddDiscardedAtToResults < ActiveRecord::Migration[7.0] - def change - add_column :results, :discarded_at, :datetime - add_index :results, :discarded_at - end -end diff --git a/db/schema.rb b/db/schema.rb index 64d1ff53b..4c04d2527 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_04_29_070135) do +ActiveRecord::Schema[7.0].define(version: 2024_01_18_094253) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" enable_extension "pg_trgm" @@ -984,12 +984,10 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_29_070135) do t.bigint "restored_by_id" t.datetime "restored_on", precision: nil t.integer "assets_view_mode", default: 0 - t.datetime "discarded_at" t.index "trim_html_tags((name)::text) gin_trgm_ops", name: "index_results_on_name", using: :gin t.index ["archived"], name: "index_results_on_archived" t.index ["archived_by_id"], name: "index_results_on_archived_by_id" t.index ["created_at"], name: "index_results_on_created_at" - t.index ["discarded_at"], name: "index_results_on_discarded_at" t.index ["last_modified_by_id"], name: "index_results_on_last_modified_by_id" t.index ["my_module_id"], name: "index_results_on_my_module_id" t.index ["restored_by_id"], name: "index_results_on_restored_by_id" From d078d0f8b037ef70203ccb3ee13aaa4479c2b651 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 12 Jun 2024 14:27:28 +0200 Subject: [PATCH 2/2] Bump version to 1.35.0.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2aeaa11ee..b6247ec7e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.35.0 +1.35.0.1