From: Vincent Vanwaelscappel Date: Thu, 22 Jun 2023 19:02:16 +0000 (+0200) Subject: wip #6015 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2a045226d173d1cfcb4b8f50d968ef0702640909;p=fluidbook-toolbox.git wip #6015 @1 --- diff --git a/app/Fluidbook/Stats.php b/app/Fluidbook/Stats.php index ae9265ac0..f6b2b8ad9 100644 --- a/app/Fluidbook/Stats.php +++ b/app/Fluidbook/Stats.php @@ -513,39 +513,60 @@ class Stats extends Reporting $undefined = ['Nom d\'évènement indéfini']; $res = []; - foreach ($types as $type => $actions) { - $data = $this->apiCall('Events.getName', ['segment' => 'eventCategory==' . $type, 'secondaryDimension' => 'eventAction', 'flat' => 1, 'expanded' => 1]); - foreach ($data as $day => $events) { - foreach ($events as $event) { - if (!in_array($event['Events_EventAction'], $actions)) { - continue; - } - if (in_array($event['Events_EventName'], $undefined)) { - continue; - } - $e = explode('|:|', $event['Events_EventName'], 2); - $page = ''; - if (count($e) == 2) { - $page = $e[1]; - $label = $e[0]; - } else { - $label = $e[0]; - } - if($page){ - $page=$this->_getPageGroup($page); - } - 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']); - } + + $categoryByName = []; + $data = $this->apiCall('Events.getCategory', ['flat' => 1, 'expanded' => 1, 'secondaryDimension' => 'eventName']); + foreach ($data as $day => $events) { + foreach ($events as $event) { + if (!isset($types[$event['Events_EventCategory']])) { + continue; + } + if (!isset($categoryByName[$event['Events_EventName']])) { + $categoryByName[$event['Events_EventName']] = $event['Events_EventCategory']; } + } + } + $data = $this->apiCall('Events.getName', ['flat' => 1, 'expanded' => 1, 'secondaryDimension' => 'eventAction']); + + foreach ($data as $day => $events) { + foreach ($events as $event) { + $name = $event['Events_EventName']; + + if (in_array($event['Events_EventName'], $undefined)) { + continue; + } + if (!isset($categoryByName[$name])) { + continue; + } + $type = $categoryByName[$name]; + $actions = $types[$type]; + $action = $event['Events_EventAction']; + if (!in_array($action, $actions)) { + continue; + } + $e = explode('|:|', $name, 2); + $page = ''; + if (count($e) == 2) { + $page = $e[1]; + $label = $e[0]; + } else { + $label = $e[0]; + } + if ($page) { + $page = $this->_getPageGroup($page); + } + 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'); diff --git a/resources/views/fluidbook_stats/stats.blade.php b/resources/views/fluidbook_stats/stats.blade.php index f29aaae2a..c6f846b0a 100644 --- a/resources/views/fluidbook_stats/stats.blade.php +++ b/resources/views/fluidbook_stats/stats.blade.php @@ -182,8 +182,8 @@ @if($summary_key === 'page_group') @include('fluidbook_stats.pagelink',['group'=>$page_data[$summary_key]]) @else - format($page_data[$summary_key]) : $page_data[$summary_key] !!} + + {!! is_int($page_data[$summary_key]) ? $formatter->format($page_data[$summary_key]) : $page_data[$summary_key] !!} @endif @endforeach @@ -192,6 +192,36 @@ + @if($multimedia->isNotEmpty()) + @php + $icons=['slideshow'=>'las la-image','video'=>'las la-video']; + @endphp + +

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

+ + + + + + + + + + + @foreach($multimedia as $label=>$media) + + + @include('fluidbook_stats.pagelink',['group'=>$media['pages'][0]??'']) + + + @endforeach + +
{{ __('Contenu') }}{{ __('Page') }}{{ __('Vues') }}
+ {{$label }} + {{ $formatter->format($media['nb']) }}
+ + @endif + {{-- Additional stats tables organised into columns (outgoing links, search keywords and countries) --}} {{-- Sometimes there are no stats for certain categories, so the number of columns adapts accordingly --}}
@@ -272,35 +302,6 @@
@endif - @if($multimedia->isNotEmpty()) - @php - $icons=['slideshow'=>'las la-image','video'=>'las la-video']; - @endphp -
-

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

- - - - - - - - - - - @foreach($multimedia as $label=>$media) - - - @include('fluidbook_stats.pagelink',['group'=>$media['pages'][0]??'']) - - - @endforeach - -
{{ __('Contenu') }}{{ __('Page') }}{{ __('Vues') }}
- {{$label }} - {{ $formatter->format($media['nb']) }}
-
- @endif