Add result comments to demo project

Closes [SCI-3100].
This commit is contained in:
Jure Grabnar 2019-02-26 17:46:35 +01:00
parent 576520659c
commit 0fbbe8b5de
2 changed files with 36 additions and 26 deletions

View file

@ -19,7 +19,8 @@ module DelayedUploaderDemo
current_team:,
result_name:,
created_at: Time.now,
file_name:
file_name:,
comment: nil
)
temp_asset = get_asset(current_user, current_team, file_name)
temp_result = Result.new(
@ -32,6 +33,10 @@ module DelayedUploaderDemo
temp_result.save
temp_asset.save
# Generate comment if it exists
generate_result_comment(temp_result, current_user, comment) if comment
temp_asset.post_process_file(my_module.experiment.project.team)
# Create result activity
@ -57,4 +62,24 @@ module DelayedUploaderDemo
step.assets << temp_asset
temp_asset.post_process_file(step.my_module.experiment.project.team)
end
def self.generate_result_comment(result, user, message, created_at = nil)
ResultComment.create(
user: user,
message: message,
created_at: created_at,
result: result
)
Activity.new(
type_of: :add_comment_to_result,
user: user,
project: result.my_module.experiment.project,
my_module: result.my_module,
created_at: created_at,
updated_at: created_at,
message: I18n.t('activities.add_comment_to_result',
user: user.full_name,
result: result.name)
).sneaky_save
end
end

View file

@ -798,11 +798,12 @@ module FirstTimeDataGenerator
user: user
)
qpcr_id = MyModule.where(name: 'qPCR').last.id.base62_encode
generate_result_comment(
DelayedUploaderDemo.generate_result_comment(
temp_result,
user,
user_annotation + ' Please check if results match results in ' \
'[#qPCR~tsk~' + qpcr_id + ']'
'[#qPCR~tsk~' + qpcr_id + ']',
generate_random_time(temp_result.created_at, 1.days)
)
temp_result.table = Table.new(
created_by: user,
@ -833,7 +834,8 @@ module FirstTimeDataGenerator
current_team: team,
result_name: 'Agarose gel electrophoresis of totRNA samples',
created_at: generate_random_time(my_modules[2].created_at, 3.days),
file_name: 'totRNA_gel.jpg'
file_name: 'totRNA_gel.jpg',
comment: user_annotation + ' Could you check if this is okay?'
)
# ----------------- Module 4 ------------------
@ -1249,7 +1251,11 @@ module FirstTimeDataGenerator
current_team: team,
result_name: 'Bacteria plates YPGA',
created_at: generate_random_time(my_modules[5].created_at, 2.days),
file_name: 'Bacterial_colonies.jpg'
file_name: 'Bacterial_colonies.jpg',
comment: user_annotation + ' please check the results again. ' \
'<span class=\"atwho-inserted\" contenteditable=\"false\"' \
'data-atwho-at-query=\"#\">[#' + fifth_rep_item + ']</span>' \
' seems to be acting strange?'
)
DelayedUploaderDemo.delay(queue: asset_queue).generate_result_asset(
@ -1669,27 +1675,6 @@ module FirstTimeDataGenerator
).sneaky_save
end
def generate_result_comment(result, user, message, created_at = nil)
created_at ||= generate_random_time(result.created_at, 1.days)
ResultComment.create(
user: user,
message: message,
created_at: created_at,
result: result
)
Activity.new(
type_of: :add_comment_to_result,
user: user,
project: result.my_module.experiment.project,
my_module: result.my_module,
created_at: created_at,
updated_at: created_at,
message: I18n.t('activities.add_comment_to_result',
user: user.full_name,
result: result.name)
).sneaky_save
end
def generate_step_comment(step, user, message, created_at = nil)
created_at ||= generate_random_time(step.created_at, 2.hours)
StepComment.create(