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

dev #37100 performances: for fetch limit for record comments

parent 4fbe3083
Branches
Tags
10 merge requests!1587Master,!1553Master,!1519Master,!1505Stable,!1502Master,!1501Stable,!1491Master,!1490Hotline master,!1489Stable,!1476Dev#37100 optimisation du code cote navigateur pour casqy
...@@ -158,6 +158,7 @@ class AvisNoticeLoader extends Storm_Model_Loader { ...@@ -158,6 +158,7 @@ class AvisNoticeLoader extends Storm_Model_Loader {
$preferences = array_merge(['id_panier' => 0, $preferences = array_merge(['id_panier' => 0,
'id_catalogue' => 0, 'id_catalogue' => 0,
'abon_ou_bib' => 'all', 'abon_ou_bib' => 'all',
'nb_aff_avis' => 10,
], ],
$preferences); $preferences);
...@@ -171,8 +172,9 @@ class AvisNoticeLoader extends Storm_Model_Loader { ...@@ -171,8 +172,9 @@ class AvisNoticeLoader extends Storm_Model_Loader {
$this->_addStatutAbonBibWhereClause($abon_ou_bib, $params); $this->_addStatutAbonBibWhereClause($abon_ou_bib, $params);
if ($limit_page) $params['limitPage'] = $limit_page
$params['limitPage'] = $limit_page; ? $limit_page
: [1, $preferences['nb_aff_avis'] * 3];
return Class_AvisNotice::findAllBy($params); return Class_AvisNotice::findAllBy($params);
} }
......
...@@ -865,6 +865,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -865,6 +865,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
->with(['order' => 'DATE_AVIS DESC', ->with(['order' => 'DATE_AVIS DESC',
'clef_oeuvre' => ['POTTER'], 'clef_oeuvre' => ['POTTER'],
'flags' => '0', 'flags' => '0',
'limitPage' => [1, 30],
'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)'])
->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated]); ->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated]);
...@@ -882,6 +883,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -882,6 +883,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
'clef_oeuvre' => ['POTTER'], 'clef_oeuvre' => ['POTTER'],
'ABON_OU_BIB' => 0, 'ABON_OU_BIB' => 0,
'flags' => 0, 'flags' => 0,
'limitPage' => [1, 30],
'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)'])
->answers([$this->_avis_abon_moderated]); ->answers([$this->_avis_abon_moderated]);
...@@ -898,6 +900,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -898,6 +900,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
'clef_oeuvre' => ['POTTER'], 'clef_oeuvre' => ['POTTER'],
'ABON_OU_BIB' => 1, 'ABON_OU_BIB' => 1,
'flags' => 0, 'flags' => 0,
'limitPage' => [1, 30],
'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)'])
->answers([$this->_avis_bib_moderated]); ->answers([$this->_avis_bib_moderated]);
...@@ -916,6 +919,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -916,6 +919,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
'clef_oeuvre' => ['POTTER'], 'clef_oeuvre' => ['POTTER'],
'ABON_OU_BIB' => 0, 'ABON_OU_BIB' => 0,
'flags' => 0, 'flags' => 0,
'limitPage' => [1, 30],
'where' => '(STATUT=1 OR ABON_OU_BIB=0)']) 'where' => '(STATUT=1 OR ABON_OU_BIB=0)'])
->answers([$this->_avis_abon_moderated, $this->_avis_abon_not_moderated]); ->answers([$this->_avis_abon_moderated, $this->_avis_abon_not_moderated]);
...@@ -934,6 +938,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -934,6 +938,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
->with(['order' => 'DATE_AVIS DESC', ->with(['order' => 'DATE_AVIS DESC',
'clef_oeuvre' => ['POTTER'], 'clef_oeuvre' => ['POTTER'],
'flags' => 0, 'flags' => 0,
'limitPage' => [1, 30],
'where' => '(STATUT=1 OR ABON_OU_BIB=0)']) 'where' => '(STATUT=1 OR ABON_OU_BIB=0)'])
->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated, $this->_avis_abon_not_moderated]); ->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated, $this->_avis_abon_not_moderated]);
...@@ -943,6 +948,26 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -943,6 +948,26 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
} }
/** @test */
public function withNbAffTwoAvisShouldLimitPageToSix() {
Class_AdminVar::newInstanceWithId('MODO_AVIS', ['valeur' => 0]);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AvisNotice')
->whenCalled('findAllBy')
->with(['order' => 'DATE_AVIS DESC',
'clef_oeuvre' => ['POTTER'],
'flags' => 0,
'limitPage' => [1, 6],
'where' => '(STATUT=1 OR ABON_OU_BIB=0)'])
->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated, $this->_avis_abon_not_moderated]);
$this->assertEquals([$this->_avis_bib_moderated, $this->_avis_abon_moderated, $this->_avis_abon_not_moderated],
Class_AvisNotice::getAvisFromPreferences(['id_panier' => 1,
'nb_aff_avis' => 2,
'abon_ou_bib' => 'all']));
}
/** @test */ /** @test */
public function withAPosterioriBibModerationAllAvisShouldReturnModeratedRatingFromAbon() { public function withAPosterioriBibModerationAllAvisShouldReturnModeratedRatingFromAbon() {
...@@ -954,6 +979,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -954,6 +979,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
->with(['order' => 'DATE_AVIS DESC', ->with(['order' => 'DATE_AVIS DESC',
'clef_oeuvre' => ['POTTER'], 'clef_oeuvre' => ['POTTER'],
'flags' => 0, 'flags' => 0,
'limitPage' => [1, 30],
'where' => '(STATUT=1 OR ABON_OU_BIB=1)']) 'where' => '(STATUT=1 OR ABON_OU_BIB=1)'])
->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]); ->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]);
...@@ -978,6 +1004,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ...@@ -978,6 +1004,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase {
->whenCalled('findAllBy') ->whenCalled('findAllBy')
->with(['order' => 'DATE_AVIS DESC', ->with(['order' => 'DATE_AVIS DESC',
'flags' => 0, 'flags' => 0,
'limitPage' => [1, 30],
'id_notice' => -1]) 'id_notice' => -1])
->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]); ->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]);
......
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