Skip to content

Commit

Permalink
revert major export change
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht committed Jan 13, 2025
1 parent 86d6363 commit 28c5c3e
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions app/models/assistant/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,9 @@ def import_from_file(path: Rails.root.join(DEFAULT_ASSISTANT_FILE), users: User.
assistants.each do |assistant|
assistant = assistant.with_indifferent_access
users.each do |user|
existing = user.assistants.not_deleted.find_by(slug: assistant["slug"])
if existing
existing.assign_attributes(assistant.except("slug", "language_model_api_name"))
existing.language_model_api_name = assistant["language_model_api_name"]
existing.save!
elsif !user.assistants.where(slug: assistant["slug"]).where.not(deleted_at: nil).exists?
attrs = assistant.except("language_model_api_name")
new_assistant = user.assistants.new(attrs)
new_assistant.language_model_api_name = assistant["language_model_api_name"]
new_assistant.save!
end
asst = user.assistants.find_or_create_by(slug: assistant["slug"])
asst.assign_attributes(assistant.except("slug")) if asst.deleted_at.nil?
asst.save!
end
end
end
Expand Down

0 comments on commit 28c5c3e

Please sign in to comment.