diff --git a/app/models/doi.rb b/app/models/doi.rb index ec1a70990..ab5a1acc6 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -349,9 +349,10 @@ def self.import_one(doi: nil) [a.to_sym, meta[a]] end.to_h.merge(schema_version: meta["schema_version"] || "http://datacite.org/schema/kernel-4", version_info: meta["version"], xml: string) + # update_attributes will trigger validations and Elasticsearch indexing doi.update_attributes(attrs) logger.info "[MySQL] Imported metadata for DOI " + doi.doi + "." - rescue TypeError, NoMethodError => error + rescue TypeError, NoMethodError, ActiveRecord::LockWaitTimeout => error logger.error "[MySQL] Error importing metadata for " + doi.doi + ": " + error.message end @@ -382,6 +383,7 @@ def self.import_by_day(options={}) [a.to_sym, meta[a]] end.to_h.merge(schema_version: meta["schema_version"] || "http://datacite.org/schema/kernel-4", version_info: meta["version"], xml: string) + # update_columns will NOT trigger validations and Elasticsearch indexing doi.update_columns(attrs) rescue TypeError, NoMethodError, ActiveRecord::LockWaitTimeout => error logger.error "[MySQL] Error importing metadata for " + doi.doi + ": " + error.message @@ -411,7 +413,8 @@ def self.import_missing(options={}) [a.to_sym, meta[a]] end.to_h.merge(schema_version: meta["schema_version"] || "http://datacite.org/schema/kernel-4", version_info: meta["version"], xml: string) - doi.update_columns(attrs) + # update_attributes will trigger validations and Elasticsearch indexing + doi.update_attributes(attrs) rescue TypeError, NoMethodError, ActiveRecord::LockWaitTimeout => error logger.error "[MySQL] Error importing metadata for " + doi.doi + ": " + error.message else