From 11064c8924079803688f1b725d77b739077a9268 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sun, 23 Sep 2018 19:38:01 +0200 Subject: [PATCH] properly handle repository object. datacite/datacite#336 --- app/models/client.rb | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index 6a4f88b22..75cfd5a5f 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -88,31 +88,7 @@ class Client < ActiveRecord::Base # include parent objects indexes :provider, type: :object - indexes :repository, type: :object, properties: { - type: { type: :keyword }, - id: { type: :keyword }, - url: { type: :text }, - repository_name: { type: :text }, - repository_url: { type: :text }, - repository_contacts: { type: :text }, - description: { type: :text }, - certificates: { type: :text }, - types: { type: :text }, - additional_names: { type: :text }, - subjects: { type: :text }, - content_types: { type: :text }, - provider_types: { type: :text }, - keywords: { type: :text }, - institutions: { type: :text }, - data_accesses: { type: :text }, - data_uploads: { type: :text }, - data_upload_licenses: { type: :text }, - pid_systems: { type: :text }, - apis: { type: :text }, - software: { type: :text }, - created: { type: :date }, - updated: { type: :date } - } + indexes :repository, type: :object end end @@ -136,8 +112,9 @@ def as_indexed_json(options={}) "created" => created, "updated" => updated, "deleted_at" => deleted_at, + "cached_doi_count" => cached_doi_count, "provider" => provider.as_indexed_json, - "repository" => repository + "repository" => cached_repository } end @@ -180,8 +157,12 @@ def repository_id=(value) write_attribute(:re3data, value) end + def cached_repository + cached_repository_response(re3data) if re3data.present? + end + def repository - OpenStruct.new(cached_repository_response(re3data)) if re3data.present? + OpenStruct.new(cached_repository) end def target_id=(value)