From b4fc837ecbb8b650f82ff5b423c0ff9ceb9af671 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 11 May 2020 18:55:30 -0300 Subject: [PATCH] mejorar la performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gracias a rack-mini-profiler nos dimos cuenta que este método no guardaba los resultados y calculaba cada vez de forma ineficiente, usando demasiada ram. --- app/models/metadata_document_date.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/metadata_document_date.rb b/app/models/metadata_document_date.rb index bd46c5a5..f49aaa7d 100644 --- a/app/models/metadata_document_date.rb +++ b/app/models/metadata_document_date.rb @@ -10,13 +10,12 @@ class MetadataDocumentDate < MetadataTemplate # El valor puede ser un Date, Time o una String en el formato # "yyyy-mm-dd" def value - return self[:value] if self[:value].is_a? Date - return self[:value] if self[:value].is_a? Time + return self[:value] = document.date || default_value if self[:value].nil? - begin - self[:value] = Date.parse(self[:value]).to_time - rescue ArgumentError, TypeError - document.date || default_value + if self[:value].is_a? String + self[:value] = Date.iso8601(self[:value]).to_time end + + self[:value] end end