mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
follow @okriuchykhin 's suggestions
This commit is contained in:
parent
83db7ed01d
commit
22eb4121f0
3 changed files with 21 additions and 12 deletions
|
@ -13,7 +13,7 @@ module Tasks
|
||||||
created_by: team.created_by
|
created_by: team.created_by
|
||||||
)
|
)
|
||||||
return repository if repository.save
|
return repository if repository.save
|
||||||
prepare_repository(team, copy_num += 1)
|
prepare_repository(team, copy_num + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.prepare_text_value_custom_columns(team, repository)
|
def self.prepare_text_value_custom_columns(team, repository)
|
||||||
|
@ -65,7 +65,7 @@ module Tasks
|
||||||
repository: repository,
|
repository: repository,
|
||||||
created_by_id: repository.created_by_id,
|
created_by_id: repository.created_by_id,
|
||||||
data_type: :RepositoryTextValue,
|
data_type: :RepositoryTextValue,
|
||||||
name: 'Sample group color hex (e980a0f5)'
|
name: 'Sample group color hex'
|
||||||
)
|
)
|
||||||
|
|
||||||
sample_type = RepositoryColumn.create!(
|
sample_type = RepositoryColumn.create!(
|
||||||
|
@ -131,12 +131,16 @@ module Tasks
|
||||||
samples.name AS sample_name,
|
samples.name AS sample_name,
|
||||||
samples.user_id AS sample_created_by_id,
|
samples.user_id AS sample_created_by_id,
|
||||||
samples.last_modified_by_id AS sample_last_modified_by_id,
|
samples.last_modified_by_id AS sample_last_modified_by_id,
|
||||||
|
samples.created_at AS sample_created_at,
|
||||||
|
samples.updated_at AS sample_updated_at,
|
||||||
sample_types.name AS sample_type_name,
|
sample_types.name AS sample_type_name,
|
||||||
sample_groups.name AS sample_group_name,
|
sample_groups.name AS sample_group_name,
|
||||||
sample_groups.color AS sample_group_color
|
sample_groups.color AS sample_group_color
|
||||||
FROM samples
|
FROM samples
|
||||||
LEFT OUTER JOIN sample_types ON samples.sample_type_id = sample_types.id
|
LEFT OUTER JOIN sample_types
|
||||||
LEFT OUTER JOIN sample_groups ON samples.sample_type_id = sample_groups.id
|
ON samples.sample_type_id = sample_types.id
|
||||||
|
LEFT OUTER JOIN sample_groups
|
||||||
|
ON samples.sample_type_id = sample_groups.id
|
||||||
WHERE samples.team_id = #{team.id}
|
WHERE samples.team_id = #{team.id}
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,16 @@ namespace :samples_to_repository_migration do
|
||||||
|
|
||||||
team_samples.each do |item|
|
team_samples.each do |item|
|
||||||
created_by = item['sample_created_by_id'] || team.created_by_id
|
created_by = item['sample_created_by_id'] || team.created_by_id
|
||||||
last_modified_by = item['sample_last_modified_by_id'] || team.created_by_id
|
last_modified_by = item['sample_last_modified_by_id']
|
||||||
row = RepositoryRow.create!(name: item['sample_name'],
|
last_modified_by ||= team.created_by_id
|
||||||
created_by_id: created_by,
|
row = RepositoryRow.create!(
|
||||||
last_modified_by_id: last_modified_by,
|
name: item['sample_name'],
|
||||||
repository: repository)
|
created_at: item['sample_created_at'],
|
||||||
|
updated_at: item['sample_updated_at'],
|
||||||
|
created_by_id: created_by,
|
||||||
|
last_modified_by_id: last_modified_by,
|
||||||
|
repository: repository
|
||||||
|
)
|
||||||
# check if sample has sample type assigned
|
# check if sample has sample type assigned
|
||||||
if item['sample_type_name']
|
if item['sample_type_name']
|
||||||
column = custom_columns.detect { |el| el['name'] == 'Sample type' }
|
column = custom_columns.detect { |el| el['name'] == 'Sample type' }
|
||||||
|
@ -61,7 +66,7 @@ namespace :samples_to_repository_migration do
|
||||||
# assign sample group color to the sample
|
# assign sample group color to the sample
|
||||||
if item['sample_group_color']
|
if item['sample_group_color']
|
||||||
column = custom_columns.detect do |el|
|
column = custom_columns.detect do |el|
|
||||||
el['name'] == 'Sample group color hex (e980a0f5)'
|
el['name'] == 'Sample group color hex'
|
||||||
end
|
end
|
||||||
RepositoryTextValue.create!(
|
RepositoryTextValue.create!(
|
||||||
data: item['sample_group_color'],
|
data: item['sample_group_color'],
|
||||||
|
|
|
@ -87,7 +87,7 @@ describe Tasks::SamplesToRepositoryMigrationService do
|
||||||
it { expect(subject.first.data_type).to eq 'RepositoryListValue' }
|
it { expect(subject.first.data_type).to eq 'RepositoryListValue' }
|
||||||
it { expect(subject.second.name).to eq 'Sample type' }
|
it { expect(subject.second.name).to eq 'Sample type' }
|
||||||
it { expect(subject.second.data_type).to eq 'RepositoryListValue' }
|
it { expect(subject.second.data_type).to eq 'RepositoryListValue' }
|
||||||
it { expect(subject.last.name).to eq 'Sample group color hex (e980a0f5)' }
|
it { expect(subject.last.name).to eq 'Sample group color hex' }
|
||||||
it { expect(subject.last.data_type).to eq 'RepositoryTextValue' }
|
it { expect(subject.last.data_type).to eq 'RepositoryTextValue' }
|
||||||
|
|
||||||
describe 'generated list items from sample types' do
|
describe 'generated list items from sample types' do
|
||||||
|
@ -142,7 +142,7 @@ describe Tasks::SamplesToRepositoryMigrationService do
|
||||||
it { expect(subject.first.data_type).to eq 'RepositoryListValue' }
|
it { expect(subject.first.data_type).to eq 'RepositoryListValue' }
|
||||||
it { expect(subject.second.name).to eq 'Sample type' }
|
it { expect(subject.second.name).to eq 'Sample type' }
|
||||||
it { expect(subject.second.data_type).to eq 'RepositoryListValue' }
|
it { expect(subject.second.data_type).to eq 'RepositoryListValue' }
|
||||||
it { expect(subject.last.name).to eq 'Sample group color hex (e980a0f5)' }
|
it { expect(subject.last.name).to eq 'Sample group color hex' }
|
||||||
it { expect(subject.last.data_type).to eq 'RepositoryTextValue' }
|
it { expect(subject.last.data_type).to eq 'RepositoryTextValue' }
|
||||||
|
|
||||||
describe 'generated list items from sample groups' do
|
describe 'generated list items from sample groups' do
|
||||||
|
|
Loading…
Reference in a new issue