Skip to content
Snippets Groups Projects
Commit aa8b9efe authored by Laurent's avatar Laurent
Browse files

hotline #46763: image cache creation: not batched anymore + add some informations for debugging

parent 9fbf8d26
Branches
Tags
5 merge requests!1797Master,!1778Master,!1777Hotline master,!1776Stable,!1770hotline #46763: image cache creation: not batched anymore + add some informations for debugging
- ticket #46763 : Constitution du cache des images: ajout d'informations pour diagnostic + traitement image par image pour éviter les timeout
\ No newline at end of file
......@@ -83,31 +83,28 @@ class Admin_SystemeController extends Zend_Controller_Action {
public function makecacheimagesAction() {
// nombre de notices a traiter en 1 appel
$limit = 10;
// nombre a traiter
$nb_a_traiter = Class_Notice::countBy(['url_vignette' => '']);
// Traitement
if($nb_a_traiter) {
// Lecture notices
$notices = Class_Notice::findAllBy(['url_vignette' => '',
'order' => 'id_notice',
'limit' => $limit]);
foreach($notices as $notice) {
$notice->fetchUrlLocalVignette();
$nb_a_traiter--;
}
if ($records_count = Class_Notice::countBy(['url_vignette' => ''])) {
$record = Class_Notice::findFirstBy(['url_vignette' => '']);
$record->fetchUrlLocalVignette();
}
// Retour infos
$this->getHelper('ViewRenderer')->setNoRender();
if($nb_a_traiter > 0)
$script = '<script>makeCacheImages("/admin/systeme/makecacheimages")</script>';
print($nb_a_traiter . $script);
exit;
$html = $records_count - 1;
if ($next_record = Class_Notice::findFirstBy(['url_vignette' => ''])) {
$html .= $this->view->tag('div',
$this->view->tag('a',
$next_record->getTitrePrincipal() . ' (' . $next_record->getAuteurPrincipal() . ')',
['href' => $this->view->urlNotice($next_record,
[],
null,
true),
'target' => '_blank']));
$html .= '<script>makeCacheImages("/admin/systeme/makecacheimages")</script>';
}
$this->getResponse()->setBody($html);
}
......
......@@ -160,4 +160,68 @@ class SystemeControllerPHPInfoActionTest extends Admin_AbstractControllerTestCas
$this->assertXPathContentContains('//div[@class="menuGaucheAdmin"]//a[contains(@href, "systeme/phpinfo")]',
'Informations système');
}
}
\ No newline at end of file
}
class SystemeControllerImageCacheTest extends Admin_AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture('Class_Notice',
['id' => 1,
'titre_principal' => 'Tintin',
'url_vignette' => '']);
$this->fixture('Class_Notice',
['id' => 2,
'titre_principal' => 'Cortomaltese',
'auteur_principal' => 'Hugo Pratt',
'url_vignette' => '']);
$mock_http = Storm_Test_ObjectWrapper::mock();
$mock_http
->whenCalled('open_url')
->answers(['statut_recherche' => 0]);
Class_WebService_AllServices::setHttpClient($mock_http);
}
public function tearDown() {
Class_WebService_AllServices::setHttpClient(null);
parent::tearDown();
}
/** @test */
public function withNoRecordLeftShouldAnswerZero() {
Class_Notice::find(1)
->setUrlVignette('thumb')
->assertSave();
$this->dispatch('/admin/systeme/makecacheimages', true);
$this->assertSame('0', $this->_response->getBody());
}
/** @test */
public function withTwoRecordsTintinAndCortomalteseShouldDislayOneCortomaltese() {
$this->dispatch('/admin/systeme/makecacheimages', true);
$this
->assertEquals('1'.
'<div>' .
'<a href="/recherche/viewnotice/id/2" target="_blank">' .
'Cortomaltese (Hugo Pratt)' .
'</a>' .
'</div>' .
'<script>makeCacheImages("/admin/systeme/makecacheimages")</script>',
$this->_response->getBody());
}
}
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