Skip to content

Commit

Permalink
Merge pull request #129 from alphagov/remove-limit
Browse files Browse the repository at this point in the history
Remove body content size limit
  • Loading branch information
csutter authored Nov 29, 2023
2 parents 9237f58 + 09194c6 commit 3194fa7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
7 changes: 0 additions & 7 deletions app/models/concerns/publishing_api/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ module Content
].map { JsonPath.new(_1, use_symbols: true) }.freeze
INDEXABLE_CONTENT_SEPARATOR = "\n".freeze

# The limit of content length on Discovery Engine API is currently 500KB, so we need to truncate
# the content to a reasonable size.
#
# TODO: Try and get limit increased?
INDEXABLE_CONTENT_MAX_BYTE_SIZE = 480.kilobytes

# Extracts a single string of indexable unstructured content from the document.
def content
values_from_json_paths = INDEXABLE_CONTENT_VALUES_JSON_PATHS.map do |item|
Expand All @@ -66,7 +60,6 @@ def content
.flatten
.compact_blank
.join(INDEXABLE_CONTENT_SEPARATOR)
.truncate_bytes(INDEXABLE_CONTENT_MAX_BYTE_SIZE)
end
end
end
14 changes: 0 additions & 14 deletions spec/models/concerns/publishing_api/content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@
it { is_expected.to eq("<h1>Foo</h1>\nbar\n<h1>Bar</h1>\n<blink>baz</blink>") }
end

describe "with excessively large content" do
let(:document_hash) do
{
details: {
body: "a" * 600.kilobytes,
},
}
end

it "truncates the content" do
expect(extracted_content.bytesize).to be <= 500.kilobytes
end
end

describe "without any fields" do
let(:document_hash) do
{
Expand Down

0 comments on commit 3194fa7

Please sign in to comment.