Improve activity records creation in controllers [SCI-7505]

This commit is contained in:
Oleksii Kriuchykhin 2022-11-24 15:19:17 +01:00
parent c2be99abda
commit 3b474fc9f0
24 changed files with 53 additions and 56 deletions

View file

@ -218,7 +218,7 @@ class AssetsController < ApplicationController
log_step_activity(
:task_step_file_deleted,
@assoc,
@assoc.my_module.experiment.project,
@assoc.my_module.project,
my_module: @assoc.my_module.id,
file: @asset.file_name
)
@ -298,7 +298,7 @@ class AssetsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: step.protocol,
team: current_team,
team: step.protocol.team,
project: project,
message_items: message_items)
end
@ -308,8 +308,8 @@ class AssetsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: result,
team: result.my_module.experiment.project.team,
project: result.my_module.experiment.project,
team: result.my_module.team,
project: result.my_module.project,
message_items: {
result: result.id,
type_of_result: t('activities.result_type.text')

View file

@ -41,8 +41,8 @@ module AssetsActions
.call(activity_type: :edit_image_on_result,
owner: current_user,
subject: asset.result,
team: my_module.experiment.project.team,
project: my_module.experiment.project,
team: my_module.team,
project: my_module.project,
message_items: {
result: asset.result.id,
asset_name: { id: asset.id, value_for: 'file_name' },

View file

@ -104,8 +104,8 @@ module BioEddieActions
.call(activity_type: "#{activity}_molecule_on_result".to_sym,
owner: current_user,
subject: result,
team: my_module.experiment.project.team,
project: my_module.experiment.project,
team: my_module.team,
project: my_module.project,
message_items: message_items)
end
end

View file

@ -118,8 +118,8 @@ module MarvinJsActions
.call(activity_type: (activity + '_chemical_structure_on_result').to_sym,
owner: current_user,
subject: result,
team: my_module.experiment.project.team,
project: my_module.experiment.project,
team: my_module.team,
project: my_module.project,
message_items: message_items)
end
@ -137,8 +137,8 @@ module MarvinJsActions
.call(activity_type: (activity + '_chemical_structure_on_task').to_sym,
owner: current_user,
subject: my_module,
team: my_module.experiment.project.team,
project: my_module.experiment.project,
team: my_module.team,
project: my_module.project,
message_items: message_items)
end

View file

@ -410,7 +410,7 @@ class ExperimentsController < ApplicationController
Activities::CreateActivityService
.call(activity_type: type_of,
owner: current_user,
team: experiment.project.team,
team: experiment.team,
project: experiment.project,
subject: experiment,
message_items: { experiment: experiment.id })

View file

@ -135,7 +135,7 @@ class MyModuleRepositoriesController < ApplicationController
activity_type: :export_inventory_items_assigned_to_task,
owner: current_user,
subject: @my_module,
team: current_team,
team: @repository.team,
message_items: {
my_module: @my_module.id,
repository: @repository.id
@ -251,7 +251,7 @@ class MyModuleRepositoriesController < ApplicationController
owner: current_user,
subject: @my_module,
team: @repository.team,
project: @my_module.experiment.project,
project: @my_module.project,
message_items: {
repository: @repository.id,
repository_row: module_repository_row.repository_row_id,

View file

@ -114,7 +114,7 @@ class MyModuleRepositorySnapshotsController < ApplicationController
activity_type: :export_inventory_snapshot_items_assigned_to_task,
owner: current_user,
subject: @my_module,
team: current_team,
team: @my_module.team,
message_items: {
my_module: @my_module.id,
repository_snapshot: @repository_snapshot.id,

View file

@ -70,9 +70,8 @@ class MyModuleTagsController < ApplicationController
.call(activity_type: :add_task_tag,
owner: current_user,
subject: my_module,
project:
my_module.experiment.project,
team: current_team,
project: my_module.project,
team: my_module.team,
message_items: {
my_module: my_module.id,
tag: @mt.tag.id
@ -95,9 +94,8 @@ class MyModuleTagsController < ApplicationController
.call(activity_type: :remove_task_tag,
owner: current_user,
subject: @mt.my_module,
project:
@mt.my_module.experiment.project,
team: current_team,
project: @mt.my_module.project,
team: @mt.my_module.team,
message_items: {
my_module: @mt.my_module.id,
tag: @mt.tag.id
@ -139,9 +137,8 @@ class MyModuleTagsController < ApplicationController
.call(activity_type: :remove_task_tag,
owner: current_user,
subject: tag.my_module,
project:
tag.my_module.experiment.project,
team: current_team,
project: tag.my_module.project,
team: tag.my_module.team,
message_items: {
my_module: tag.my_module.id,
tag: tag.tag.id

View file

@ -456,8 +456,8 @@ class MyModulesController < ApplicationController
Activities::CreateActivityService
.call(activity_type: type_of,
owner: current_user,
team: my_module.experiment.project.team,
project: my_module.experiment.project,
team: my_module.team,
project: my_module.project,
subject: my_module,
message_items: message_items)
end

View file

@ -622,7 +622,7 @@ class ProtocolsController < ApplicationController
.call(activity_type: :import_protocol_in_repository,
owner: current_user,
subject: protocol,
team: current_team,
team: protocol.team,
message_items: {
protocol: protocol.id
})
@ -820,15 +820,15 @@ class ProtocolsController < ApplicationController
file_name = 'protocols.eln'
end
@protocols.each do |p|
@protocols.each do |protocol|
if params[:my_module_id]
my_module = MyModule.find(params[:my_module_id])
Activities::CreateActivityService
.call(activity_type: :export_protocol_from_task,
owner: current_user,
project: my_module.experiment.project,
project: my_module.project,
subject: my_module,
team: current_team,
team: my_module.team,
message_items: {
my_module: params[:my_module_id].to_i
})
@ -836,10 +836,10 @@ class ProtocolsController < ApplicationController
Activities::CreateActivityService
.call(activity_type: :export_protocol_in_repository,
owner: current_user,
subject: p,
team: current_team,
subject: protocol,
team: protocol.team,
message_items: {
protocol: p.id
protocol: protocol.id
})
end
end
@ -1232,7 +1232,7 @@ class ProtocolsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @protocol,
team: current_team,
team: @protocol.team,
project: project,
message_items: message_items)
end

View file

@ -521,7 +521,7 @@ class RepositoriesController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @repository,
team: current_team,
team: @repository.team,
message_items: message_items)
end
end

View file

@ -167,7 +167,7 @@ class RepositoryColumnsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @repository,
team: current_team,
team: @repository.team,
message_items: {
repository_column: @repository_column.id,
repository: @repository.id

View file

@ -432,7 +432,7 @@ class RepositoryRowsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: repository_row,
team: current_team,
team: @repository.team,
message_items: {
repository_row: repository_row.id,
repository: @repository.id

View file

@ -191,8 +191,8 @@ class ResultAssetsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: result,
team: @my_module.experiment.project.team,
project: @my_module.experiment.project,
team: @my_module.team,
project: @my_module.project,
message_items: {
result: result.id,
type_of_result: t('activities.result_type.asset')

View file

@ -180,8 +180,8 @@ class ResultTablesController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @result,
team: @my_module.experiment.project.team,
project: @my_module.experiment.project,
team: @my_module.team,
project: @my_module.project,
message_items: {
result: @result.id,
type_of_result: t('activities.result_type.table')

View file

@ -206,8 +206,8 @@ class ResultTextsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @result,
team: @my_module.experiment.project.team,
project: @my_module.experiment.project,
team: @my_module.team,
project: @my_module.project,
message_items: {
result: @result.id,
type_of_result: t('activities.result_type.text')

View file

@ -14,8 +14,8 @@ class ResultsController < ApplicationController
.call(activity_type: :destroy_result,
owner: current_user,
subject: @result,
team: @my_module.experiment.project.team,
project: @my_module.experiment.project,
team: @my_module.team,
project: @my_module.project,
message_items: { result: @result.id,
type_of_result: result_type })
flash[:success] = t('my_modules.module_archive.delete_flash',

View file

@ -78,8 +78,8 @@ class StepCommentsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @protocol,
team: current_team,
project: @step.my_module.experiment.project,
team: @step.my_module.team,
project: @step.my_module.project,
message_items: {
my_module: @step.my_module.id,
step: @step.id,

View file

@ -40,8 +40,8 @@ module StepElements
Activities::CreateActivityService.call(
activity_type: "#{!@step.protocol.in_module? ? 'protocol_step_' : 'task_step_'}#{element_type_of}",
owner: current_user,
team: @protocol.in_module? ? @protocol.my_module.experiment.project.team : @protocol.team,
project: @protocol.in_module? ? @protocol.my_module.experiment.project : nil,
team: @protocol.team,
project: @protocol.in_module? ? @protocol.my_module.project : nil,
subject: @protocol,
message_items: {
step: @step.id,

View file

@ -144,7 +144,7 @@ module StepElements
owner: current_user,
subject: @step.protocol,
team: @step.protocol.team,
project: @step.protocol.in_module? ? @step.protocol.my_module.experiment.project : nil,
project: @step.protocol.in_module? ? @step.protocol.my_module.project : nil,
message_items: message_items.merge(step_message_items)
)
end

View file

@ -48,7 +48,7 @@ class StepOrderableElementsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @protocol,
team: current_team,
team: @protocol.team,
project: project,
message_items: message_items)
end

View file

@ -38,7 +38,7 @@ class StepsController < ApplicationController
@asset = @step.assets.create!(
created_by: current_user,
last_modified_by: current_user,
team: current_team,
team: @protocol.team,
view_mode: @step.assets_view_mode
)
@asset.file.attach(params[:signed_blob_id])
@ -323,7 +323,7 @@ class StepsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: @protocol,
team: current_team,
team: @protocol.team,
project: project,
message_items: message_items)
end

View file

@ -168,7 +168,7 @@ class TagsController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: subject,
team: current_team,
team: @tag.project.team,
project: @tag.project,
message_items: message_items)
end

View file

@ -97,7 +97,7 @@ class TeamRepositoriesController < ApplicationController
.call(activity_type: type_of,
owner: current_user,
subject: team_shared_object.shared_repository,
team: current_team,
team: @repository.team,
message_items: { repository: team_shared_object.shared_repository.id,
team: team_shared_object.team.id,
permission_level: