From fecec06452ec64d31bedc79d6c2fd5c70bd3d02e Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Fri, 2 Oct 2020 10:29:59 +0200 Subject: [PATCH] Fix rake task for types Added more types and also case of blank agency --- app/models/doi.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 79829a879..21f056923 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -2325,9 +2325,31 @@ def self.add_index_type(options={}) Doi.where(id: from_id..until_id).where('type' => nil).find_each(batch_size: 500) do |doi| begin - if doi.agency.casecmp?("datacite") + if doi.agency.blank? || doi.agency.casecmp?("datacite") type = "DataciteDoi" - elsif doi.agency.casecmp?("crossref") + else + type = "OtherDoi" + end + + agency = doi.agency + + if agency.blank? || agency.casecmp?("datacite") + type = "DataciteDoi" + elsif agency.casecmp?("crossref") + type = "OtherDoi" + elsif agency.casecmp?("kisti") + type = "OtherDoi" + elsif agency.casecmp?("medra") + type = "OtherDoi" + elsif agency.casecmp?("istic") + type = "OtherDoi" + elsif agency.casecmp?("jalc") + type = "OtherDoi" + elsif agency.casecmp?("airiti") + type = "OtherDoi" + elsif agency.casecmp?("cnki") + type = "OtherDoi" + elsif agency.casecmp?("op") type = "OtherDoi" else type = "DataciteDoi"