From f54e5d84f7a1569ad0ab82cbe7eb7166449f8c27 Mon Sep 17 00:00:00 2001 From: 1M4 Date: Wed, 13 Jun 2018 09:39:06 +0200 Subject: [PATCH 1/5] #543 SchemaBundle: Changed limit search in LastestUploads --- .../SchemaBundle/Services/AnnounceService.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Pumukit/SchemaBundle/Services/AnnounceService.php b/src/Pumukit/SchemaBundle/Services/AnnounceService.php index 05135773e..d7a33b0ad 100644 --- a/src/Pumukit/SchemaBundle/Services/AnnounceService.php +++ b/src/Pumukit/SchemaBundle/Services/AnnounceService.php @@ -118,18 +118,24 @@ public function getLatestUploadsByDates($dateStart, $dateEnd, $withPudenewTag = */ public function getNextLatestUploads($date, $withPudenewTag = true) { - $counter = 0; $dateStart = clone $date; $dateStart->modify('first day of next month'); $dateEnd = clone $date; $dateEnd->modify('last day of next month'); $dateEnd->setTime(23, 59, 59); + + $queryBuilderMms = $this->mmobjRepo->createQueryBuilder(); + $queryBuilderMms->sort('public_date', 'asc'); + $queryBuilderMms->field('tags.cod')->equals('PUDENEW'); + $queryBuilderMms->limit(1); + + $lastMm = $queryBuilderMms->getQuery()->getSingleResult(); + do { - ++$counter; $dateStart->modify('first day of last month'); $dateEnd->modify('last day of last month'); $last = $this->getLatestUploadsByDates($dateStart, $dateEnd, $withPudenewTag); - } while (empty($last) && $counter < 24); + } while (empty($last) && $lastMm->getPublicDate() <= $dateEnd); return array($dateEnd, $last); } From 7a6e3cf888fcbe709d8727eb0bf354784dc6e2b6 Mon Sep 17 00:00:00 2001 From: 1M4 Date: Wed, 13 Jun 2018 10:14:29 +0200 Subject: [PATCH 2/5] Hotfix 543 use php cs fixer --- src/Pumukit/SchemaBundle/Services/AnnounceService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pumukit/SchemaBundle/Services/AnnounceService.php b/src/Pumukit/SchemaBundle/Services/AnnounceService.php index d7a33b0ad..f93e7cf13 100644 --- a/src/Pumukit/SchemaBundle/Services/AnnounceService.php +++ b/src/Pumukit/SchemaBundle/Services/AnnounceService.php @@ -128,7 +128,7 @@ public function getNextLatestUploads($date, $withPudenewTag = true) $queryBuilderMms->sort('public_date', 'asc'); $queryBuilderMms->field('tags.cod')->equals('PUDENEW'); $queryBuilderMms->limit(1); - + $lastMm = $queryBuilderMms->getQuery()->getSingleResult(); do { From 4ae5fcfe49f36d12e17d16d223eff35e58852e56 Mon Sep 17 00:00:00 2001 From: 1M4 Date: Wed, 13 Jun 2018 13:09:01 +0200 Subject: [PATCH 3/5] Hotfix 543 tests corrected --- .../SchemaBundle/Services/AnnounceService.php | 4 ++++ .../Tests/Services/AnnounceServiceTest.php | 14 ++------------ .../WebTVBundle/Controller/AnnouncesController.php | 14 ++++++++------ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Pumukit/SchemaBundle/Services/AnnounceService.php b/src/Pumukit/SchemaBundle/Services/AnnounceService.php index f93e7cf13..1605fad50 100644 --- a/src/Pumukit/SchemaBundle/Services/AnnounceService.php +++ b/src/Pumukit/SchemaBundle/Services/AnnounceService.php @@ -137,6 +137,10 @@ public function getNextLatestUploads($date, $withPudenewTag = true) $last = $this->getLatestUploadsByDates($dateStart, $dateEnd, $withPudenewTag); } while (empty($last) && $lastMm->getPublicDate() <= $dateEnd); + if (empty($last)) { + $dateEnd = null; + } + return array($dateEnd, $last); } } diff --git a/src/Pumukit/SchemaBundle/Tests/Services/AnnounceServiceTest.php b/src/Pumukit/SchemaBundle/Tests/Services/AnnounceServiceTest.php index 7230cb34f..2f2f5b721 100644 --- a/src/Pumukit/SchemaBundle/Tests/Services/AnnounceServiceTest.php +++ b/src/Pumukit/SchemaBundle/Tests/Services/AnnounceServiceTest.php @@ -4,9 +4,6 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Pumukit\SchemaBundle\Document\Series; -use Pumukit\SchemaBundle\Document\SeriesType; -use Pumukit\SchemaBundle\Document\MultimediaObject; -use Pumukit\SchemaBundle\Document\Role; use Pumukit\SchemaBundle\Document\Tag; class AnnounceServiceTest extends WebTestCase @@ -93,6 +90,7 @@ public function testGetLast() $this->assertEquals(array(), $this->announceService->getLast()); } + public function testNextLatestUploads() { $tagPudenew = new Tag(); @@ -147,14 +145,6 @@ public function testNextLatestUploads() $dateEnd->modify('first day of last month'); list($dateEnd, $last) = $this->announceService->getNextLatestUploads($dateEnd); $this->assertEquals(array(), $last); - $this->assertEquals('04/1997', $dateEnd->format('m/Y')); - $dateEnd->modify('first day of last month'); - list($dateEnd, $last) = $this->announceService->getNextLatestUploads($dateEnd); - $this->assertEquals(array(), $last); - $this->assertEquals('04/1995', $dateEnd->format('m/Y')); - $dateEnd->modify('first day of last month'); - list($dateEnd, $last) = $this->announceService->getNextLatestUploads($dateEnd, false); - $this->assertEquals(array(), $last); - $this->assertEquals('04/1993', $dateEnd->format('m/Y')); + $this->assertEquals(null, $dateEnd); } } diff --git a/src/Pumukit/WebTVBundle/Controller/AnnouncesController.php b/src/Pumukit/WebTVBundle/Controller/AnnouncesController.php index e996cd5ca..46ec38835 100644 --- a/src/Pumukit/WebTVBundle/Controller/AnnouncesController.php +++ b/src/Pumukit/WebTVBundle/Controller/AnnouncesController.php @@ -40,16 +40,18 @@ public function latestUploadsPagerAction(Request $request) throw $this->createNotFoundException(); } list($date, $last) = $announcesService->getNextLatestUploads($date, $showPudenew); - if (empty($last)) { - $dateHeader = '---'; - } else { + + $response = new Response(); + $dateHeader = '---'; + + if (!empty($last)) { + $response = new Response($this->renderView('PumukitWebTVBundle:Announces:latestUploadsPager.html.twig', array('last' => $last, 'date' => $date, 'number_cols' => $numberCols)), 200); $dateHeader = $date->format('m/Y'); + $response->headers->set('X-Date-Month', $date->format('m')); + $response->headers->set('X-Date-Year', $date->format('Y')); } - $response = new Response($this->renderView('PumukitWebTVBundle:Announces:latestUploadsPager.html.twig', array('last' => $last, 'date' => $date, 'number_cols' => $numberCols)), 200); $response->headers->set('X-Date', $dateHeader); - $response->headers->set('X-Date-Month', $date->format('m')); - $response->headers->set('X-Date-Year', $date->format('Y')); return $response; } From a2c6573dee4556a81da45086d9cdf20a48c7355b Mon Sep 17 00:00:00 2001 From: 1M4 Date: Mon, 18 Jun 2018 12:27:51 +0200 Subject: [PATCH 4/5] Hotfix 543 showing message when there arent MMOs --- src/Pumukit/SchemaBundle/Services/AnnounceService.php | 2 +- .../WebTVBundle/Resources/public/js/announces_ajax.js | 8 ++++++-- .../WebTVBundle/Resources/translations/messages.es.xlf | 4 ++++ .../Resources/views/Announces/latestUploads.html.twig | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Pumukit/SchemaBundle/Services/AnnounceService.php b/src/Pumukit/SchemaBundle/Services/AnnounceService.php index 1605fad50..9ad7843c0 100644 --- a/src/Pumukit/SchemaBundle/Services/AnnounceService.php +++ b/src/Pumukit/SchemaBundle/Services/AnnounceService.php @@ -135,7 +135,7 @@ public function getNextLatestUploads($date, $withPudenewTag = true) $dateStart->modify('first day of last month'); $dateEnd->modify('last day of last month'); $last = $this->getLatestUploadsByDates($dateStart, $dateEnd, $withPudenewTag); - } while (empty($last) && $lastMm->getPublicDate() <= $dateEnd); + } while (empty($last) && $lastMm && $lastMm->getPublicDate() <= $dateEnd); if (empty($last)) { $dateEnd = null; diff --git a/src/Pumukit/WebTVBundle/Resources/public/js/announces_ajax.js b/src/Pumukit/WebTVBundle/Resources/public/js/announces_ajax.js index ff8b65a8b..d32f74d7b 100644 --- a/src/Pumukit/WebTVBundle/Resources/public/js/announces_ajax.js +++ b/src/Pumukit/WebTVBundle/Resources/public/js/announces_ajax.js @@ -32,8 +32,9 @@ jQuery(document).ready(function() { }; var now = new Date(); var anDate = new AnnounceDate( now.getMonth() + 1, now.getFullYear() ); + var emptyMmos = true; - function reloadMoreData() + function reloadMoreData(emptyMmos) { if( month_loaded && !in_array(anDate,loaded_months)) { @@ -53,11 +54,14 @@ jQuery(document).ready(function() { if( $('.main-content').height() <= $(window).height() ) { reloadMoreData(); } + }else if( emptyMmos ){ + emptyMmos = false; + $(noMmo).show(); } }); } } - reloadMoreData(); + reloadMoreData(emptyMmos); $(window).scroll(function () { if ($(window).scrollTop() + window.innerHeight + $('footer').height() >= $(document).height()) { reloadMoreData(); diff --git a/src/Pumukit/WebTVBundle/Resources/translations/messages.es.xlf b/src/Pumukit/WebTVBundle/Resources/translations/messages.es.xlf index f101f63be..480597748 100644 --- a/src/Pumukit/WebTVBundle/Resources/translations/messages.es.xlf +++ b/src/Pumukit/WebTVBundle/Resources/translations/messages.es.xlf @@ -472,6 +472,10 @@ Try searching for something else: Prueba a buscar otra cosa: + + There are no multimedia objects + No hay objetos multimedia + diff --git a/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig b/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig index 8a61d91f7..34f095840 100644 --- a/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig +++ b/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig @@ -9,8 +9,14 @@

{{template_title}}

+ + {# añadir mensaje hidden para mostrar cuando no haya MMOs #} {% endblock %} From 415692b381889481e1ba0394630edc44ef6caee4 Mon Sep 17 00:00:00 2001 From: 1M4 Date: Mon, 18 Jun 2018 12:29:59 +0200 Subject: [PATCH 5/5] Hotfix 543 comment in code deleted --- .../Resources/views/Announces/latestUploads.html.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig b/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig index 34f095840..27b5f6c5f 100644 --- a/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig +++ b/src/Pumukit/WebTVBundle/Resources/views/Announces/latestUploads.html.twig @@ -18,5 +18,4 @@ - {# añadir mensaje hidden para mostrar cuando no haya MMOs #} {% endblock %}