feat: update document doc
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
class AddDocumentTypeAndExternalIdToCaptainDocuments < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :captain_documents, :document_type, :integer, default: 0, null: false
|
||||
add_column :captain_documents, :external_id, :string
|
||||
|
||||
add_index :captain_documents, :document_type
|
||||
add_index :captain_documents, [:assistant_id, :external_id, :document_type],
|
||||
unique: true,
|
||||
name: 'index_captain_documents_unique_external_id'
|
||||
end
|
||||
end
|
||||
@@ -27,8 +27,10 @@ class Captain::Document < ApplicationRecord
|
||||
has_many :responses, class_name: 'Captain::AssistantResponse', dependent: :destroy, as: :documentable
|
||||
belongs_to :account
|
||||
|
||||
validates :external_link, presence: true
|
||||
validates :external_link, uniqueness: { scope: :assistant_id }
|
||||
validates :external_link, presence: true, if: :web?
|
||||
validates :external_link, uniqueness: { scope: :assistant_id }, if: :web?
|
||||
validates :external_id, presence: true, if: :notion?
|
||||
validates :external_id, uniqueness: { scope: [:assistant_id, :document_type] }, allow_nil: true
|
||||
validates :content, length: { maximum: 200_000 }
|
||||
before_validation :ensure_account_id
|
||||
|
||||
@@ -37,6 +39,11 @@ class Captain::Document < ApplicationRecord
|
||||
available: 1
|
||||
}
|
||||
|
||||
enum document_type: {
|
||||
web: 0,
|
||||
notion: 1
|
||||
}
|
||||
|
||||
before_create :ensure_within_plan_limit
|
||||
after_create_commit :enqueue_crawl_job
|
||||
after_create_commit :update_document_usage
|
||||
|
||||
Reference in New Issue
Block a user