Commit fb6cf332 authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch…

Merge branch 'hotline#106079_anomalie_sur_les_facettes_import_des_periodiques_chambery_nouvelle_conf' into 'hotline'

hotline #106079 Cosmogramme : - when variable date_maj_facettes is reset, ensure…

See merge request !3407
parents d09d74c6 483b321d
Pipeline #9554 failed with stage
in 35 minutes and 19 seconds
- ticket #106079 : Correction de l'import de l'indexation des facettes exemplaires lorsqu'une notice a plus de 1000 exemplaires
\ No newline at end of file
......@@ -21,27 +21,34 @@
class CodifAnnexeCache {
static $_instance;
use Trait_Singleton;
protected $_cache = [];
protected
$_cache_by_code,
$_cache_by_id_origine;
public static function getInstance() {
if (!isset(static::$_instance))
static::$_instance = new static();
return static::$_instance;
protected function _generateCache() {
$this->_cache_by_code = [];
$this->_cache_by_id_origine = [];
foreach (Class_CodifAnnexe::findAll() as $annex) {
$this->_cache_by_code[$annex->getCode()] = $annex;
$this->_cache_by_id_origine[$annex->getIdOrigine()] = $annex;
}
}
public function find($key) {
if (isset($this->_cache[$key]))
return $this->_cache[$key];
if (!isset($_cache_by_code))
$this->_generateCache();
if (isset($this->_cache_by_code[$key]))
return $this->_cache_by_code[$key];
if ($model = Class_CodifAnnexe::findFirstBy(['code' => $key]))
return $this->_cache[$key] = $model;
if (isset($this->_cache_by_id_origine[$key]))
return $this->_cache_by_id_origine[$key];
return $this->_cache[$key] = Class_CodifAnnexe::findFirstBy(['id_origine' => $key]);
return null;
}
}
?>
\ No newline at end of file
......@@ -420,7 +420,10 @@ class notice_integration {
$this->notice['exemplaires'] = [ ['code_barres' => sprintf('%s-%s',
$this->id_int_bib,
$this->notice["id_origine"])] ];
$this->notice['id_origine'] = $this->analyseur->getIssn();
if ($issn = $this->analyseur->getIssn())
$this->notice['id_origine'] = $issn;
return $this;
}
......
......@@ -564,7 +564,7 @@ class notice_unimarc extends iso2709_record {
if ($champ_annexe and $champ['code'] == $champ_annexe) {
$annexe = CodifAnnexeCache::getInstance()->find($champ['valeur']);
if ($champ['valeur'] && $this->isAnnexeInvisible($champ['valeur']))
if ($annexe && !$annexe->isVisible())
$ex['ignore_exemplaire'] = true;
$ex['annexe'] = ($annexe) ? $annexe->getCode() : $champ['valeur'];
}
......
......@@ -441,6 +441,7 @@ abstract class KohaPeriodiquesWithArticlesTestCase extends KohaPeriodiquesTestCa
->setTypeDocRecognition(Class_TypeDoc::PERIODIQUE, '', 'PER')
->setTypeDocRecognition(Class_TypeDoc::PERIODIQUE_TITLE, 'as', '')
->setTypeDocField('h')
->setAnnexField('b')
->getRawAttributes();
}
}
......@@ -451,15 +452,46 @@ abstract class KohaPeriodiquesWithArticlesTestCase extends KohaPeriodiquesTestCa
class KohaPeriodiquesMatriculeAngesTest extends KohaPeriodiquesWithArticlesTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_CodifAnnexe',
['id' => 3,
'id_origine' => 'CHY-JR',
'code' => 'CHYJR',
'libelle' => 'Bibliothèque Jean-Jacques Rousseau']);
$this->loadRecordsFromFile('unimarc_lettre_spectacle');
$this->loadRecordsFromFile('unimarc_article_matricule_ange');
$this->loadRecordsFromFile('unimarc_article_matricule_ange2');
$this->loadRecordsFromFile('unimarc_serial_matricule_ange');
foreach(Class_Notice::findAll() as $record)
$record->updateFacetsFromExemplaires();
}
/** @test */
public function numberOfRecordsShouldBe54() {
$this->assertEquals(54, count(Class_Notice::findAll()));
}
/** @test */
public function numberOfRecordsShouldBe52() {
$this->assertEquals(52, count(Class_Notice::findAll()));
public function secondItemIdOrigineShouldBe519682fromRecord001() {
$item = Class_Exemplaire::find(2);
$this->assertEquals('519682', $item->getIdOrigine());
}
/** @test */
public function numberOfItemsShouldBe57() {
$this->assertCount(57, Class_Exemplaire::findAll());
}
/** @test */
public function lettreSpectacleTitleShouldHaveOneItem() {
$this->assertEquals(1,
Class_Notice::findFirstBy(['clef_chapeau' => 'LETTRE DU SPECTACLE'])->numberOfExemplaires());
}
......@@ -510,8 +542,8 @@ class KohaPeriodiquesMatriculeAngesTest extends KohaPeriodiquesWithArticlesTestC
/** @test */
public function twoRecordsShouldHaveTypeDocPERIODIQUE_TITLE() {
$this->assertCount(2,
public function threeRecordsShouldHaveTypeDocPERIODIQUE_TITLE() {
$this->assertCount(3,
Class_Notice::findAllBy(['type_doc' => Class_TypeDoc::PERIODIQUE_TITLE]));
}
......@@ -588,6 +620,16 @@ class KohaPeriodiquesMatriculeAngesTest extends KohaPeriodiquesWithArticlesTestC
$this->assertEquals('111511 Matricule des Anges (Le) 179',
$record->getAllStringsInFields([['461', '9'], ['461', 't'], ['461', 'v'],]));
}
/** @test */
public function allMatriculeAngesSerialFacettesShouldContainsYCHYJR() {
$records = Class_Notice::findAllBy(['type_doc' => Class_TypeDoc::PERIODIQUE,
'clef_chapeau' => 'MATRICULE DES ANGES LE']);
foreach($records as $index => $record)
$this->assertContains('YCHYJR', $record->getFacettes(),
'at position: ' . $index . ', title: ' . $record->getTitrePrincipal());
}
}
......
......@@ -21,6 +21,7 @@
require_once 'classe_notice_integration.php';
require_once 'classe_notice_marc21.php';
require_once 'classe_codif_cache.php';
require_once 'ModelTestCase.php';
......@@ -68,6 +69,8 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase {
$sql = $this->_mock_sql = $this->mock();
profil_donnees::clearCache();
CodifAnnexeCache::resetInstance();
$this->_mock_sql
->whenCalled('execute')->answers(true)
->whenCalled('fetchAll')->answers(null)
......
00618nas 22001693 4500001000700000090001100007100004100018101000800059102000700067200012200074210003100196215001500227326001600242676000800258801004900266995013300315519682 a519682 a20190717a1999 u||u0frey50 ba afre aFR aLa Lettre du spectaclebPériodiqueeL'information des professionnels du spectacle vivantf[dir. publ. Nicolas Marc] aNantesc M Médiasd1999- an°d30 cm aBimensuelle eBDP aFRbCité des Arts - Chambéryc2019/07/17 10203052019-07-179549426bCHY-CAcCHY-CAe905fCHY-CA19070271hPERi2019-07-17o0rPRETNORMALvn°454, juil. 2019y2019-07-17
\ No newline at end of file
......@@ -57,7 +57,7 @@ class Class_Cosmogramme_Integration_PhaseItemFacets
$this->_cleanMemory();
}
Class_CosmoVar::setValueOf('date_maj_facettes', $this->_last_update_date);
Class_CosmoVar::setValueOf('date_maj_facettes', $this->getCurrentDateTime());
$this->_log->log('<span class="vert">'.
'Toutes les exemplaires ont été mis à jour :' .
......@@ -80,8 +80,17 @@ class Class_Cosmogramme_Integration_PhaseItemFacets
return $this->_resetDbConnection()
->_phase;
if (static::MAX_ITEMS < Class_Exemplaire::countBy(['id_notice' => $record->getId()]))
return;
if (static::MAX_ITEMS < Class_Exemplaire::countBy(['id_notice' => $record->getId()])) {
$this->_log->error('<span class="rouge">'
. $this->_('La notice "%s" (id: %s) a plus de %s exemplaires: facettes non mises à jour',
$record->getTitrePrincipal(),
$record->getId(),
static::MAX_ITEMS)
. '</span>');
$this->_setData('pointeur_notice', $record->getId());
$this->_incrementData('nombre');
continue;
}
$this->_runOne($record);
}
......@@ -96,7 +105,6 @@ class Class_Cosmogramme_Integration_PhaseItemFacets
$this->_setData('pointeur_notice', $record->getId());
$this->_incrementData('nombre');
$this->_last_update_date = $record->getDateMaj();
}
......
......@@ -969,6 +969,10 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
return $this->setItemField(self::FIELD_ITEM_TYPE_DOC, $value);
}
public function setAnnexField($value) {
return $this->setItemField(self::FIELD_ITEM_ANNEXE, $value);
}
public function setAvailabilityField($value) {
return $this->setItemField(self::FIELD_ITEM_AVAILABILITY, $value);
......
Subproject commit 1bc8fe711c57d051aca40c463b05e495a06a265f
Subproject commit 7aaada2df1e203d1fb50685dafe371de1ac034a5
......@@ -59,12 +59,28 @@ class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase {
['id' => 'date_maj_facettes',
'valeur' => '']);
Class_Cosmogramme_Integration_PhaseItemFacets::setTimeSource(new TimeSourceForTest('2020-02-17 10:00:00'));
$this
->onLoaderOfModel('Class_Notice')
->whenCalled('findAllAfter')
->with(0, '0000-00-00 00:00:00')
->answers([$this->fixture('Class_Notice',
['id' => 1,
'titre_principal' => 'Les animaniacs',
'date_maj' => '2015-04-05 15:08:34']),
$this->fixture('Class_Notice',
['id' => 2,
'titre_principal' => 'Les cassetouts',
'date_maj' => '2015-04-05 15:08:34'])]);
$this
->onLoaderOfModel('Class_Exemplaire')
->whenCalled('countBy')
->with(['id_notice' => 2])
->answers(2000);
}
......@@ -80,15 +96,21 @@ class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase {
}
/** @test */
public function logShouldContainsRecordTwoHasMoreThan1000Items() {
$this->assertLogContains('La notice "Les cassetouts" (id: 2) a plus de 1000 exemplaires');
}
/** @test */
public function logShouldContainsProcessedRecordCount() {
$this->assertLogContains('1 notices traitées');
$this->assertLogContains('2 notices traitées');
}
/** @test */
public function lastFacetsUpdateDateShouldBeSet() {
$this->assertNotEmpty(Class_CosmoVar::getValueOf('date_maj_facettes'));
public function lastFacetsUpdateDateShouldBeCurrentDateTime() {
$this->assertEquals('2020-02-17 10:00:00', Class_CosmoVar::getValueOf('date_maj_facettes'));
}
}
......@@ -108,6 +130,7 @@ abstract class PhaseItemFacetsCallbackTest extends PhaseItemFacetsTestCase {
$this
->onLoaderOfModel('Class_Notice')
->whenCalled('findAllAfter')
->with(0, '0000-00-00 00:00:00')
->answers([$this->fixture('Class_Notice',
['id' => 1,
'date_maj' => '2015-04-05 15:08:34'])]);
......@@ -127,6 +150,7 @@ class PhaseItemFacetsExpectedExceptionPhaseTest extends PhaseItemFacetsTestCase
$this
->onLoaderOfModel('Class_Notice')
->whenCalled('findAllAfter')
->with(0, '0000-00-00 00:00:00')
->answers('error');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment