Skip to content

Commit

Permalink
metadata_date should be in the form YYYY-MM-DD
Browse files Browse the repository at this point in the history
Some of the records captured from CKAN have time info which elasticsearch will reject.
  • Loading branch information
kentsanggds committed Dec 11, 2023
1 parent b2e16ea commit 9f422d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/models/ckan/v26/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ def get(key)
@package[key]
end

def get_extra(key)
def get_extra(key, max_length = 0)
@extras ||= hashify(@package["extras"] || [])
@extras[key]
if max_length.positive? && @extras[key].present?
@extras[key][0, max_length]
else
@extras[key]
end
end

def get_harvest(key)
Expand Down
2 changes: 1 addition & 1 deletion app/services/ckan/v26/inspire_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call(package)
harvest_object_id: package.get_extra("harvest_object_id") || package.get_harvest("harvest_object_id"),
harvest_source_reference: package.get_extra("harvest_source_reference"),
import_source: package.get_extra("import_source"),
metadata_date: package.get_extra("metadata-date"),
metadata_date: package.get_extra("metadata-date", 10),
metadata_language: package.get_extra("metadata-language"),
provider: package.get_extra("provider"),
resource_type: package.get_extra("resource-type"),
Expand Down
2 changes: 1 addition & 1 deletion spec/services/ckan/v26/inspire_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
expect(attributes[:harvest_object_id]).to eq package.get_extra("harvest_object_id")
expect(attributes[:harvest_source_reference]).to eq package.get_extra("harvest_source_reference")
expect(attributes[:import_source]).to eq package.get_extra("import_source")
expect(attributes[:metadata_date]).to eq package.get_extra("metadata-date")
expect(attributes[:metadata_date]).to eq package.get_extra("metadata-date", 10)
expect(attributes[:metadata_language]).to eq package.get_extra("metadata-language")
expect(attributes[:provider]).to eq package.get_extra("provider")
expect(attributes[:resource_type]).to eq package.get_extra("resource-type")
Expand Down

0 comments on commit 9f422d8

Please sign in to comment.