]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6015 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 16 Jun 2023 17:00:26 +0000 (19:00 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 16 Jun 2023 17:00:26 +0000 (19:00 +0200)
app/Fluidbook/Stats.php
resources/views/fluidbook_stats/stats.blade.php

index dc55143ed7f42140bb7e1c0181f216ddc8f21b40..562fd35a36913fded7af3127c942b5886ffec74d 100644 (file)
@@ -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
index 4ad976b74f6ee8d0ed17a710813c81fe62dafc1b..734cd8316c9de445acddc070e4e2518b07502d96 100644 (file)
@@ -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
                     <tr>
                     </tr>
                 @endforeach
 
-                <tr>
-                    <td>{{ __('Recherches') }}</td>
-                    <td>{{ $formatter->format($searches->sum()) }}</td>
-                </tr>
+                @if($searches->sum()>0)
+                    <tr>
+                        <td>{{ __('Recherches') }}</td>
+                        <td>{{ $formatter->format($searches->sum()) }}</td>
+                    </tr>
+                @endif
             @endif
         </table>
         <a id="chart"></a>
                     </div>
                 @endif
 
+                @if($multimedia->isNotEmpty())
+                    @php
+                        $icons=['slideshow'=>'las la-image','video'=>'las la-video'];
+                    @endphp
+                    <div>
+                        <h3>{{ __('Contenus multimédia') }}</h3>
+
+                        <table class="{!! $tableClasses !!}">
+                            <thead>
+                            <tr>
+                                <th style="width: 55%;">{{ __('Contenu') }}</th>
+                                <th style="width: 20%;">{{ __('Page') }}</th>
+                                <th style="width: 15%;" class="sorttable_sorted_reverse">{{ __('Vues') }}</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            @foreach($multimedia as $label=>$media)
+                                <tr>
+                                    <td class="whitespace-nowrap" data-sort-value="{{$label }}">
+                                        <i class="{{$icons[$media['type']]}}"></i> {{$label }}
+                                    </td>
+                                    <td data-sort-value="{{ $media['pages'][0] ?? 0}}">{{implode(', ',$media['pages']) }}</td>
+                                    <td>{{ $formatter->format($media['nb']) }}</td>
+                                </tr>
+                            @endforeach
+                            </tbody>
+                        </table>
+                    </div>
+                @endif
+
             </div>