Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
Add new fields to the extraction definition to determine if a file ne…
Browse files Browse the repository at this point in the history
…eds to have its text extracted
  • Loading branch information
richardmatthewsdev committed Mar 6, 2024
1 parent 07c5b5e commit a22bf83
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

# Ignore master key for decrypting credentials and more.
/config/master.key
/config/credentials.yml.enc

/app/assets/builds/*
!/app/assets/builds/.keep
Expand Down
3 changes: 2 additions & 1 deletion app/models/extraction_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Used to store the information for running an extraction
#
class ExtractionDefinition < ApplicationRecord
FORMATS = %w[JSON XML HTML PDF].freeze
FORMATS = %w[JSON XML HTML].freeze

# The destination is used for Enrichment Extractions
# To know where to pull the records that are to be enriched from
Expand Down Expand Up @@ -36,6 +36,7 @@ class ExtractionDefinition < ApplicationRecord

validates :name, uniqueness: true
validates :split_selector, presence: true, if: :split?
validates :extracted_file_format, presence: true, if: :extract_text_from_file?

validates :throttle, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 60_000 }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddExtractTextFromFileToExtractionDefinition < ActiveRecord::Migration[7.0]
def change
add_column :extraction_definitions, :extract_text_from_file, :boolean, default: false, null: false
add_column :extraction_definitions, :extracted_file_format, :string
end
end
4 changes: 3 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions spec/models/extraction_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@

it { is_expected.to validate_presence_of(:split_selector).with_message("can't be blank") }
end

context 'when the extraction definition needs to extract the text from a file' do
subject! { build(:extraction_definition, pipeline: pipeline1, extract_text_from_file: true) }

it { is_expected.to validate_presence_of(:extracted_file_format).with_message("can't be blank") }
end
end

describe '#validation numericality' do
Expand Down

0 comments on commit a22bf83

Please sign in to comment.