Merge pull request #6301 from G-Chubinidze/gc_SCI_9299

OVE - Activities related to Task result [SCI-9299]
This commit is contained in:
Martin Artnik 2023-09-27 12:49:58 +02:00 committed by GitHub
commit d44d29a0fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 6 deletions

View file

@ -118,8 +118,13 @@ class AssetsController < ApplicationController
object_to_update = @asset.result_asset
object_to_update.update!(result: target)
type_of = {
'marvinjs' => :move_chemical_structure_on_result,
'gene_sequence' => :sequence_on_result_moved
}.fetch(@asset.file.metadata[:asset_type], :result_file_moved)
log_result_activity(
@asset.file.metadata[:asset_type] == 'marvinjs' ? :move_chemical_structure_on_result : :result_file_moved,
type_of,
@assoc,
file: @asset.file_name,
user: current_user.id,
@ -296,7 +301,7 @@ class AssetsController < ApplicationController
end
when Result
log_result_activity(
:result_file_deleted,
@asset.file.metadata[:asset_type] == 'gene_sequence' ? :sequence_on_result_deleted : :result_file_deleted,
@assoc,
file: @asset.file_name
)

View file

@ -25,13 +25,37 @@ class GeneSequenceAssetsController < ApplicationController
def create
save_asset!
log_activity('sequence_asset_added')
case @parent
when Step
log_activity('sequence_asset_added')
when Result
log_result_activity(
:sequence_on_result_added,
@parent,
file: @asset.file_name,
user: current_user.id
)
end
head :ok
end
def update
save_asset!
log_activity('sequence_asset_edit_finished')
case @parent
when Step
log_activity('sequence_asset_edit_finished')
when Result
log_result_activity(
:sequence_on_result_edited,
@parent,
file: @asset.file_name,
user: current_user.id
)
end
head :ok
end
@ -171,4 +195,16 @@ class GeneSequenceAssetsController < ApplicationController
project: project
)
end
def log_result_activity(type_of, result, message_items)
Activities::CreateActivityService
.call(activity_type: type_of,
owner: current_user,
subject: result,
team: result.my_module.team,
project: result.my_module.project,
message_items: {
result: result.id
}.merge(message_items))
end
end

View file

@ -488,7 +488,10 @@ class Extends
result_file_moved: 284,
result_text_moved: 285,
result_table_moved: 286,
move_chemical_structure_on_result: 287
sequence_on_result_added: 287,
sequence_on_result_edited: 288,
sequence_on_result_deleted: 289,
sequence_on_result_moved: 290
}
ACTIVITY_GROUPS = {
@ -497,7 +500,8 @@ class Extends
task: [8, 58, 9, 59, *10..14, 35, 36, 37, 53, 54, *60..63, 138, 139, 140, 64, 66, 106, 126, 120, 132,
*146..148, 166, 246, 247, 248],
task_protocol: [15, 22, 16, 18, 19, 20, 21, 17, 38, 39, 100, 111, 45, 46, 47, 121, 124, 115, 118, 127, 130, 137,
217, 168, 171, 177, 184, 185, 188, 189, *192..203, 222, 224, 225, 226, 236, *249..252, *274..278],
217, 168, 171, 177, 184, 185, 188, 189, *192..203, 222, 224, 225, 226, 236, *249..252, *274..278,
*287..290],
task_inventory: [55, 56, 146, 147, 183],
experiment: [*27..31, 57, 141, 165],
reports: [48, 50, 49, 163, 164],

View file

@ -71,6 +71,10 @@ en:
result_restored_html: "%{user} restored result %{result} from archive."
result_file_added_html: "%{user} added file <strong>%{file}</strong> to result <strong>%{result}</strong>."
result_file_deleted_html: "%{user} deleted file <strong>%{file}</strong> in result <strong>%{result}</strong>."
sequence_on_result_added_html: "%{user} created sequence %{file} on result %{result}."
sequence_on_result_edited_html: "%{user} edited sequence %{file} on result %{result}."
sequence_on_result_deleted_html: "%{user} deleted sequence %{file} on result %{result}."
sequence_on_result_moved_html: "%{user} moved sequence %{file} from result %{result_original} to result %{result_destination}."
result_text_added_html: "%{user} created text <strong>%{text_name}</strong> in result <strong>%{result}</strong>."
result_text_edited_html: "%{user} edited text <strong>%{text_name}</strong> in result <strong>%{result}</strong>."
result_text_deleted_html: "%{user} deleted text <strong>%{text_name}</strong> in result <strong>%{result}</strong>."