Skip to content

Commit

Permalink
Merge pull request #153 from xiaobokuai/main
Browse files Browse the repository at this point in the history
Fix create dataset error bug
  • Loading branch information
lishengbao authored Nov 8, 2024
2 parents 4b8d2d9 + ac9f117 commit d27f793
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/graphql/mutations/create_lab_dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def resolve(
projects = get_new_dataset(nil, datasets)
end

project_url = JSON.parse(projects)
project_url.each do |project|

projects.each do |project|
CustomAnalyzeProjectServer.new(user: current_user, model: model, version: version, project: project.label).execute
end

Expand Down Expand Up @@ -141,16 +141,16 @@ def get_new_dataset(existing_content, new_datasets)
raise ValidateFailed.new(I18n.t('lab_models.invalid_dataset')) if filtered_rows.blank?
raise ValidateFailed.new(I18n.t('lab_models.datasets_too_large', limit: Limit)) if filtered_rows.length > Limit
if existing_content.nil?
return JSON.dump(filtered_rows)
filtered_rows
end
# return new_datasets if existing_content.nil?
existing_content = JSON.parse(existing_content)
existing_hash = existing_content.each_with_object({}) do |item, hash|
hash[item["label"]] = item
end
# Not in existing_content
filtered_content = new_datasets.reject { |dataset| existing_hash.key?(dataset.label) }
JSON.dump(filtered_content)
new_datasets.reject { |dataset| existing_hash.key?(dataset.label) }

end

end
Expand Down
4 changes: 4 additions & 0 deletions app/graphql/types/lab/my_model_version_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def parent_lab_model
LabModel.find_by(id: model.parent_model_id)
end

def model_name
model.name
end

def dataset_status
dataset = model.dataset
return nil unless dataset
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/queries/lab/my_model_reports_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def resolve(page: 1, per: 5)
.joins(:lab_model_version)
.where(user_id: current_user.id)
.select('lab_model_versions.id as version_id, lab_model_versions.version,
lab_model_reports.id as report_id, lab_models.name AS model_name,lab_models.id as model_id, lab_models.parent_model_id,
lab_model_reports.id as report_id, lab_models.name,lab_models.id as model_id, lab_models.parent_model_id,
lab_model_reports.*')
.order('lab_model_reports.created_at DESC'),
{ page: page, items: per })
Expand Down

0 comments on commit d27f793

Please sign in to comment.