mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-19 14:01:03 +08:00
Add comment activities to first time data generator
This commit is contained in:
parent
25928bfa0b
commit
30e8e33774
1 changed files with 126 additions and 62 deletions
|
@ -135,10 +135,10 @@ module FirstTimeDataGenerator
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add a comment
|
# Add a comment
|
||||||
project.comments << Comment.create(
|
generate_project_comment(
|
||||||
user: user,
|
project,
|
||||||
message: "I've created a demo project",
|
user,
|
||||||
created_at: generate_random_time(1.week.ago)
|
"I've created a demo project"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a module group
|
# Create a module group
|
||||||
|
@ -316,44 +316,45 @@ module FirstTimeDataGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add comments to modules
|
# Add comments to modules
|
||||||
my_modules[0].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[0],
|
||||||
message: "We should have a meeting to discuss sampling parametrs soon.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 1.day)
|
'We should have a meeting to discuss sampling parametrs soon.'
|
||||||
)
|
)
|
||||||
my_modules[0].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[0],
|
||||||
message: "I agree."
|
user,
|
||||||
|
'I agree.'
|
||||||
)
|
)
|
||||||
|
|
||||||
my_modules[1].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[1],
|
||||||
message: "The samples have arrived.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 2.days)
|
'The samples have arrived.'
|
||||||
)
|
)
|
||||||
|
|
||||||
my_modules[2].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[2],
|
||||||
message: "Due date has been postponed for a day.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 1.days)
|
'Due date has been postponed for a day.'
|
||||||
)
|
)
|
||||||
|
|
||||||
my_modules[4].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[4],
|
||||||
message: "Please show Steve the RT procedure.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 2.days)
|
'Please show Steve the RT procedure.'
|
||||||
)
|
)
|
||||||
|
|
||||||
my_modules[5].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[5],
|
||||||
message: "The results must be very definitive.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 3.days)
|
'The results must be very definitive.'
|
||||||
)
|
)
|
||||||
|
|
||||||
my_modules[7].comments << Comment.create(
|
generate_module_comment(
|
||||||
user: user,
|
my_modules[7],
|
||||||
message: "The due date here is flexible.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 3.days)
|
'The due date here is flexible.'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create tags and add them to module
|
# Create tags and add them to module
|
||||||
|
@ -422,10 +423,10 @@ module FirstTimeDataGenerator
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 1.days),
|
created_at: generate_random_time(my_modules[0].created_at, 1.days),
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
temp_result.comments << Comment.new(
|
generate_result_comment(
|
||||||
user: user,
|
temp_result,
|
||||||
message: "The table shows proposed number of biological replicates.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[0].created_at, 1.days)
|
'The table shows proposed number of biological replicates.'
|
||||||
)
|
)
|
||||||
temp_result.table = Table.new(
|
temp_result.table = Table.new(
|
||||||
created_by: user,
|
created_by: user,
|
||||||
|
@ -533,10 +534,10 @@ module FirstTimeDataGenerator
|
||||||
created_at: generate_random_time(my_modules[2].created_at, 1.days),
|
created_at: generate_random_time(my_modules[2].created_at, 1.days),
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
temp_result.comments << Comment.new(
|
generate_result_comment(
|
||||||
user: user,
|
temp_result,
|
||||||
message: "PVY NTN 6dpi isolation seems to have failed, please repeat nanodrop measurement.",
|
user,
|
||||||
created_at: generate_random_time(my_modules[2].created_at, 2.days)
|
'PVY NTN 6dpi isolation seems to have failed, please repeat nanodrop measurement.'
|
||||||
)
|
)
|
||||||
temp_result.table = Table.new(
|
temp_result.table = Table.new(
|
||||||
created_by: user,
|
created_by: user,
|
||||||
|
@ -738,12 +739,12 @@ module FirstTimeDataGenerator
|
||||||
|
|
||||||
# Add comment to step
|
# Add comment to step
|
||||||
step = my_modules[6].protocol.steps.where("position = 1").take
|
step = my_modules[6].protocol.steps.where("position = 1").take
|
||||||
step.comments << Comment.new(
|
|
||||||
user: user,
|
|
||||||
message: "What is the Cq that should be considered as positive result?",
|
|
||||||
created_at: generate_random_time(step.created_at, 2.hours)
|
|
||||||
)
|
|
||||||
step.save
|
step.save
|
||||||
|
generate_step_comment(
|
||||||
|
step,
|
||||||
|
user,
|
||||||
|
'What is the Cq that should be considered as positive result?'
|
||||||
|
)
|
||||||
|
|
||||||
# ----------------- Module 8 ------------------
|
# ----------------- Module 8 ------------------
|
||||||
module_step_names = [
|
module_step_names = [
|
||||||
|
@ -815,7 +816,7 @@ module FirstTimeDataGenerator
|
||||||
|
|
||||||
# create thumbnail
|
# create thumbnail
|
||||||
experiment.generate_workflow_img
|
experiment.generate_workflow_img
|
||||||
|
|
||||||
# Lastly, create cookie with according ids
|
# Lastly, create cookie with according ids
|
||||||
# so tutorial steps can be properly positioned
|
# so tutorial steps can be properly positioned
|
||||||
JSON.generate([
|
JSON.generate([
|
||||||
|
@ -903,27 +904,90 @@ module FirstTimeDataGenerator
|
||||||
end
|
end
|
||||||
if polite_comment
|
if polite_comment
|
||||||
commented_on = generate_random_time(completed_on)
|
commented_on = generate_random_time(completed_on)
|
||||||
step.comments << Comment.create(
|
generate_step_comment(
|
||||||
user: @user,
|
step,
|
||||||
message: polite_comment,
|
@user,
|
||||||
created_at: commented_on
|
polite_comment,
|
||||||
)
|
commented_on
|
||||||
Activity.create(
|
|
||||||
type_of: :add_comment_to_step,
|
|
||||||
project: my_module.experiment.project,
|
|
||||||
my_module: my_module,
|
|
||||||
user: @user,
|
|
||||||
created_at: commented_on,
|
|
||||||
message: I18n.t(
|
|
||||||
"activities.add_comment_to_step",
|
|
||||||
user: @user.full_name,
|
|
||||||
step: i,
|
|
||||||
step_name: step.name
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_project_comment(project, user, message, created_at = nil)
|
||||||
|
created_at ||= generate_random_time(project.created_at, 1.week)
|
||||||
|
project.comments << Comment.create(
|
||||||
|
user: user,
|
||||||
|
message: message,
|
||||||
|
created_at: created_at
|
||||||
|
)
|
||||||
|
Activity.create(
|
||||||
|
type_of: :add_comment_to_project,
|
||||||
|
user: user,
|
||||||
|
project: project,
|
||||||
|
created_at: created_at,
|
||||||
|
message: t('activities.add_comment_to_project',
|
||||||
|
user: user.full_name,
|
||||||
|
project: project.name)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_module_comment(my_module, user, message, created_at = nil)
|
||||||
|
created_at ||= generate_random_time(my_module.created_at, 1.day)
|
||||||
|
my_module.comments << Comment.create(
|
||||||
|
user: user,
|
||||||
|
message: message,
|
||||||
|
created_at: created_at
|
||||||
|
)
|
||||||
|
Activity.create(
|
||||||
|
type_of: :add_comment_to_module,
|
||||||
|
user: user,
|
||||||
|
project: my_module.experiment.project,
|
||||||
|
my_module: my_module,
|
||||||
|
created_at: created_at,
|
||||||
|
message: t('activities.add_comment_to_module',
|
||||||
|
user: user.full_name,
|
||||||
|
module: my_module.name)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_result_comment(result, user, message, created_at = nil)
|
||||||
|
created_at ||= generate_random_time(result.created_at, 1.days)
|
||||||
|
result.comments << Comment.new(
|
||||||
|
user: user,
|
||||||
|
message: message,
|
||||||
|
created_at: created_at
|
||||||
|
)
|
||||||
|
Activity.create(
|
||||||
|
type_of: :add_comment_to_result,
|
||||||
|
user: user,
|
||||||
|
project: result.my_module.experiment.project,
|
||||||
|
my_module: result.my_module,
|
||||||
|
created_at: created_at,
|
||||||
|
message: t('activities.add_comment_to_result',
|
||||||
|
user: user.full_name,
|
||||||
|
result: result.name)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_step_comment(step, user, message, created_at = nil)
|
||||||
|
created_at ||= generate_random_time(step.created_at, 2.hours)
|
||||||
|
step.comments << Comment.new(
|
||||||
|
user: user,
|
||||||
|
message: message,
|
||||||
|
created_at: created_at
|
||||||
|
)
|
||||||
|
Activity.create(
|
||||||
|
type_of: :add_comment_to_step,
|
||||||
|
user: user,
|
||||||
|
project: step.protocol.my_module.experiment.project,
|
||||||
|
my_module: step.protocol.my_module,
|
||||||
|
created_at: created_at,
|
||||||
|
message: t('activities.add_comment_to_step',
|
||||||
|
user: user.full_name,
|
||||||
|
step: step.position + 1,
|
||||||
|
step_name: step.name)
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue