From 1870a08bee9f39b363237d5822afad69cb34e157 Mon Sep 17 00:00:00 2001 From: Thiago Matos Date: Fri, 3 May 2024 18:08:53 -0400 Subject: [PATCH] Fixes metrics import --- filter/import/NativeXmlJournalFilter.inc.php | 14 +++++++++++++- locale/en_US/locale.po | 6 ++++++ locale/pt_BR/locale.po | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/filter/import/NativeXmlJournalFilter.inc.php b/filter/import/NativeXmlJournalFilter.inc.php index a0f49a0..d65c048 100644 --- a/filter/import/NativeXmlJournalFilter.inc.php +++ b/filter/import/NativeXmlJournalFilter.inc.php @@ -431,6 +431,7 @@ public function parseArticle($node, $journal) public function parseMetrics($node, $journal) { $deployment = $this->getDeployment(); + echo __('plugins.importexport.fullJournal.importingMetrics') . "\n"; $metricKeys = [ 'assoc_type', 'day', 'country_id', 'region', 'city', 'file_type', 'metric', 'metric_type', 'load_id' @@ -465,7 +466,18 @@ public function parseMetrics($node, $journal) break; } $metricsDAO = DAORegistry::getDAO('MetricsDAO'); - $metricsDAO->insertRecord($record); + try { + $metricsDAO->insertRecord($record); + } catch (Exception $e) { + $deployment->addWarning( + ASSOC_TYPE_JOURNAL, + $journal->getId(), + __( + 'plugins.importexport.fullJournal.error.metric', + ['reason' => $e->getMessage()] + ) + ); + } } } } diff --git a/locale/en_US/locale.po b/locale/en_US/locale.po index acc50e1..166c96f 100644 --- a/locale/en_US/locale.po +++ b/locale/en_US/locale.po @@ -47,8 +47,14 @@ msgstr "Importing issues..." msgid "plugins.importexport.fullJournal.importingArticles" msgstr "Importing articles..." +msgid "plugins.importexport.fullJournal.importingMetrics" +msgstr "Importing metrics..." + msgid "plugins.importexport.fullJournal.importCompleted" msgstr "Import completed successfully" msgid "plugins.importexport.fullJournal.error.userNotFound" msgstr "User with email {$email} is not present on the site." + +msgid "plugins.importexport.fullJournal.error.metric" +msgstr "Failed to import metric. {$reason}" diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index 82bd5c9..141eec0 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -47,8 +47,14 @@ msgstr "Importando edições..." msgid "plugins.importexport.fullJournal.importingArticles" msgstr "Importando artigos..." +msgid "plugins.importexport.fullJournal.importingMetrics" +msgstr "Importando métricas..." + msgid "plugins.importexport.fullJournal.importCompleted" msgstr "Importação concluída com sucesso" msgid "plugins.importexport.fullJournal.error.userNotFound" msgstr "Usuário com email {$email} não está presente no site." + +msgid "plugins.importexport.fullJournal.error.metric" +msgstr "Falha ao importar a métrica. {$reason}"