From 8839f08cb2db3e65fe06ee95ba7dfe3692b8bacf Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 16 Jun 2023 19:00:26 +0200 Subject: [PATCH] wip #6015 @2 --- app/Fluidbook/Stats.php | 42 +++++++++++++++++++ .../views/fluidbook_stats/stats.blade.php | 42 ++++++++++++++++--- 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/app/Fluidbook/Stats.php b/app/Fluidbook/Stats.php index dc55143ed..562fd35a3 100644 --- a/app/Fluidbook/Stats.php +++ b/app/Fluidbook/Stats.php @@ -226,6 +226,7 @@ class Stats extends Reporting $this->viewData->searches = $this->_processSearches(); $this->viewData->outlinks = $this->_processOutgoingLinks(); $this->viewData->countries = $this->_processCountries(); + $this->viewData->multimedia = $this->_processMultimedia(); $this->viewData->shareDetails = $this->_processShareDetails(); //=== MAIN PERIOD STATISTICS @@ -504,6 +505,47 @@ class Stats extends Reporting return collect($this->_eventsByPage['link']['subtable'] ?? [])->sortByDesc('nb_events'); } + protected function _processMultimedia() + { + $types = ['slideshow' => ['show'], 'video' => ['play', 'show']]; + + $typesSubtable = []; + foreach ($this->apiCall('Events.getCategory') as $period) { + foreach ($period as $category) { + $typesSubtable[$category['label']] = $category['idsubdatatable']; + } + } + + + $res = []; + foreach ($types as $type => $actions) { + foreach ($actions as $action) { + $data = $this->apiCall('Events.getNameFromCategoryId', ['idSubtable' => $typesSubtable[$type], 'segment' => 'eventAction==' . $action]); + foreach ($data as $day => $events) { + foreach ($events as $event) { + $label = $event['label']; + $e = explode('|:|', $label, 2); + $page = ''; + if (count($e) == 2) { + $page = $e[1]; + } + if (!isset($res[$label])) { + $res[$label] = ['type' => $type, 'nb' => 0, 'pages' => []]; + } + $res[$label]['nb'] += $event['nb_events']; + if ($page && !in_array($page, $res[$label]['pages'])) { + $res[$label]['pages'][] = $page; + sort($res[$label]['pages']); + } + } + } + } + + } + + return collect($res)->sortByDesc('nb'); + } + protected function _processCountries() { //=== COUNTRIES OF ORIGIN diff --git a/resources/views/fluidbook_stats/stats.blade.php b/resources/views/fluidbook_stats/stats.blade.php index 4ad976b74..734cd8316 100644 --- a/resources/views/fluidbook_stats/stats.blade.php +++ b/resources/views/fluidbook_stats/stats.blade.php @@ -79,7 +79,7 @@ {{-- Summary of totals --}} @if($period_details->isNotEmpty()) @foreach ($table_map['summary'] as $summary_key => $summary_heading) - @if($summary_key === 'formatted_date' || $period_details->sum($summary_key)===0) + @if($summary_key === 'formatted_date' || !$period_details->sum($summary_key)) @continue @endif @@ -98,10 +98,12 @@ @endforeach - - {{ __('Recherches') }} - {{ $formatter->format($searches->sum()) }} - + @if($searches->sum()>0) + + {{ __('Recherches') }} + {{ $formatter->format($searches->sum()) }} + + @endif @endif @@ -282,6 +284,36 @@ @endif + @if($multimedia->isNotEmpty()) + @php + $icons=['slideshow'=>'las la-image','video'=>'las la-video']; + @endphp +
+

{{ __('Contenus multimédia') }}

+ + + + + + + + + + + @foreach($multimedia as $label=>$media) + + + + + + @endforeach + +
{{ __('Contenu') }}{{ __('Page') }}{{ __('Vues') }}
+ {{$label }} + {{implode(', ',$media['pages']) }}{{ $formatter->format($media['nb']) }}
+
+ @endif + -- 2.39.5