-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewers.php
364 lines (319 loc) · 13.8 KB
/
viewers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<?php
require_once('common.php');
template('header');
?>
<div class="album py-5 bg-light">
<div class="container">
<p class="display-6 text-center ">The People</p>
<p class="lead text-center ">(They used to be your friends, but then you made them watch <span class="bg-dark text-white px-1"><strong>[REDACTED]</strong></span>.)</p>
<?php
//$streakers = get_streakers();
$time_watched = viewer_watchtime();
$viewers_longest_streaks = find_longest_streak_v2($pdo);
$longest_streak = max($viewers_longest_streaks);
$longest_streak_key = array_search(max($viewers_longest_streaks),$viewers_longest_streaks);
$current_streak = get_current_streak($pdo);
?>
<div class="row justify-content-around">
<div class="alert text-center col-5 text-white" role="alert" style="background-color:#<?php echo getMoviegoerColorById($current_streak['winner_id']);?>;">
<?php echo "<strong>Current Winning Streak: </strong>" . getMoviegoerById($current_streak['winner_id']) . " with " . $current_streak['count']; " wins! "; ?>
</div>
<div class="alert text-center col-5 text-white" role="alert" style="background-color:#<?php echo getMoviegoerColorById($longest_streak_key);?>;">
<?php echo "<strong>Longest Winning Streak: </strong>" . getMoviegoerById($longest_streak_key) . " with " . $longest_streak . " wins! "; ?>
</div>
</div>
<div class="row mt-3">
<?php $starting_time = microtime(true);?>
<table id="movies" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Atnd</th>
<th class="text-end">
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The number of events a viewer has been to.">
%
</div>
</th>
<th class="text-end">
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The number of unique movies a user has put on the wheel.">
<i class="fas fa-fingerprint"></i> <i class="fas fa-film"></i>
</div>
</th>
<th class="text-end">
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The number of total movies a user has put on the wheel.">
<i class="fal fa-ballot-check" ></i> <i class="fas fa-film"></i>
</div>
</th>
<th class="text-end">
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="% of Unique movies a user has put on the wheel.">
<i class="fas fa-fingerprint"></i> %
</div>
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The number of times a viewer's movie has been picked for movie night.">
<i class="fas fa-trophy"></i>
</div>
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The percent of movie nights a viewer has won.">
<i class="fas fa-trophy"></i> %
</div>
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title=" The percentage of attended movie nights that a viewers movie has won.">
<i class="fas fa-trophy" ></i>/Atnd
</div>
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="Streak: The most consecutive events that a viewer has had their movie watched, ignoring viewer choice nights.">
<i class="fas fa-repeat"></i> <i class="fas fa-trophy"></i>
</div>
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The longest a viewer has gone without winning (only counting attended events.)">
<i class="fas fa-cactus"></i>
</div>
</th>
<th aria-sort="ascending">
Last Spin
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The number of times a user has spun a wheel or rolled a die.">
<i class="fas fa-sync"></i>
</div>
</th>
<th class="text-end">
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="The number of minutes viewer has spent watching films.">
<i class="far fa-stopwatch"></i>
</div>
</th>
<th>
<div data-bs-toggle="tooltip" data-bs-animation='false' data-bs-placement="right" title="Average moving rating across all films viewer placed on wheel.">
<i class="fas fa-star-half-alt"></i>%
</div>
</th>
</tr>
</thead>
<tbody>
<?php
$viewer = getListOfViewers('attendance');
$total_events = countWeeks();
$full_count = count_all_attendance_v2($pdo);
$full_picker_list = count_total_picks_for_everyone($pdo);
$all_dry_spells = get_dry_spell_for_all_v2($pdo);
foreach($viewer as $person): ?>
<tr style="background-color:<?php echo HTMLToRGB($person['color']);?>;">
<?php
$attend = $full_count[$person['id']];
if(array_key_exists($person['id'],$full_picker_list)){
$myUnique = $full_picker_list[$person['id']]['unique'];
$myTotal = $full_picker_list[$person['id']]['total'];
} else {
$myUnique = 0;
$myTotal = 0;
}
$my_longest_streak = $viewers_longest_streaks[$person['id']] ?? 0;
$wins = winningPickStats($person['id']);
$spins = countMySpins_noChoice($person['id']);
$picks = countMySpins($person['id']);
?>
<td style="background-color:#<?php echo $person['color'];?>;" class="bold text-white"><?php echo $person['name'];?></td>
<td class="text-end"><?php echo $attend;?></td>
<td class="text-end"><em><?php echo round(($attend/$total_events)*100, 2)?>%</em> </td>
<td class="text-end"><?php echo $myUnique; ?></td>
<td class="text-end"><?php echo $myTotal; ?></td>
<td class="text-end">
<?php
if($myTotal == 0){ $myTotal = 1;}
echo round(($myUnique/$myTotal)*100,2);
?>%
</td>
<td class="text-end"><?php echo $wins; ?></td>
<td class="text-end"><?php echo round(($wins/$total_events)*100,2);?>%</td>
<td class="text-end"><?php echo ($attend == 0) ? 0 : round(($wins/$attend)*100,2);?>%</td>
<td class="text-end"><?php echo $my_longest_streak; ?></td>
<td class="text-end"><?php echo $all_dry_spells[$person['id']]; ?></td>
<td class="text-end"><?php echo last_spin_date($person['id']); ?></td>
<td class="text-end"><?php echo $spins['total'];?></td>
<td class="text-end"><?php echo $time_watched[$person['id']] ?? 0;?></td>
<td class="text-end"><?php echo get_viewer_ratings_real($person['id']);?>%</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php $stopping_time = microtime(true);
echo "Table calculated in " . ($stopping_time - $starting_time) . " seconds.";?>
</div>
<div class="accordion mt-1" id="accordionExample">
<div class="accordion-item">
<h2 class="accordion-header" id="headingOne">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
*Notes and definitions for above table.
</button>
</h2>
<div id="collapseOne" class="accordion-collapse collapse " aria-labelledby="headingOne" data-bs-parent="#accordionExample">
<div class="accordion-body">
<ul>
<li><strong>Name:</strong> Name. Name of viewer.</li>
<li><strong>Atnd:</strong> Attendance. The number of events a viewer has been to.</li>
<li><strong>%</strong> Attendance Percentage. The percent of total movie nights a viewer has been in attendance.</li>
<li><strong><i class="fas fa-fingerprint"></i></strong> Unique Movies. The number of unique movies a user has put on the wheel.</li>
<li><strong><i class="fal fa-ballot-check"></i></strong> Total Movies. The number of total movies a user has put on the wheel.</li>
<li><strong><i class="fas fa-fingerprint"></i>%</strong> % of Unique movies a user has put on the wheel.</li>
<li><strong><i class="fas fa-trophy"></i></strong> Wins: The number of times a viewer's movie has been picked for movie night.</li>
<li><strong><i class="fas fa-trophy"></i> %:</strong> The percent of movie nights a viewer has won.</li>
<li><strong><i class="fas fa-trophy"></i>/Atnd:</strong> The percentage of attended movie nights that a viewers movie has won.</li>
<li><strong><i class="fas fa-repeat"></i> <i class="fas fa-trophy"></i></strong> Streak: The most consecutive events that a viewer has had their movie watched, ignoring viewer choice nights.</li>
<li><strong><i class="fas fa-cactus"></i></strong> Dry: The longest a viewer has gone without winning (only counting attended events.)</li>
<li><strong>Last Spin:</strong> The date if a viewers last spin/roll. Used to determine who is up next.</li>
<li><strong><i class="fas fa-sync"></i></strong> Spins: The number of times a user has spun a wheel or rolled a die.</li>
<li><strong><i class="far fa-stopwatch"></i></strong> The number of minutes viewer has spent watching films.</li>
<li><strong><i class="fas fa-star-half-alt"></i>%</strong> Average Moving Rating across all picked films.</li>
<ul>
</div>
</div>
</div>
</div>
<div class="row g-3 mt-5">
<?php foreach($viewer as $person): ?>
<div class="col-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 col-xxl-4 mb-4">
<div class="card">
<div class="card-header bold text-white" style="background-color:#<?php echo $person['color'];?>;" >
<h3><strong><?php echo $person['name']; ?></strong></h3>
</div>
<div class="card-body">
<ul>
<li>
<strong>Spun Numbers: </strong><?php //echo implode(", ", listOfSpunNumbersByViewer($person['id']));?>
</li>
<?php //print_r(graphSpunNumbersByViewer($id));
$numbers = graphSpunNumbersByViewer($person['id']);
if(!empty($numbers)){
$max = max($numbers);
if($max == 0){$max = 1;}
}
else {
$max = 1;
}
?>
<div class="chart">
<table id="column-<?php echo $person['id'];?>" class="charts-css column show-labels show-data-on-hover">
<thead>
<tr>
<th scope="col">Number</th>
<th scope="col">Wins</th>
</tr>
</thead>
<tbody style="height: 120px;">
<?php foreach($numbers as $key => $value):?>
<tr>
<th scope="row"> <?php echo $key; ?> </th>
<td style="--size:<?php echo round($value/$max,2); ?>;"><span class="data"><?php echo $value; ?></span></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<hr >
<li><strong>Spun People: </strong></li>
<?php //echo implode(", ", getSpunViewers($person['id']));
$numbers = getSpunViewers_v2($person['id']);
if(!empty($numbers)){
$max = max($numbers);
if($max == 0){$max=1;}
}
else {
$max = 1;
}
?>
<div class="chart">
<table id="column-<?php echo $person['id'];?>" class="charts-css bar show-labels show-data">
<thead>
<tr>
<th scope="col">Number</th>
<th scope="col">Wins</th>
</tr>
</thead>
<tbody>
<?php
foreach($numbers as $key => $value):?>
<tr>
<th scope="row"> <?php echo $key; ?> </th>
<td style="--size:<?php echo round($value/$max,2); ?>; --color:#<?php echo getMoviegoerColorByName($key); ?>"><span class="data data_padding"><?php echo $value; ?></span></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</ul>
<hr >
<?php
$stats = count_viewer_services($person['id']);
$format = Array();
$count = Array();
$color = Array();
foreach($stats as $key => $value){
$format[] = $key;
$count[] = $value;
$color[] = get_service_color_v3($key);
}
if(!empty($format)): ?>
<strong>Winning Services: </strong>
<canvas id="myChart<?php echo$person['id'];?>" width="250" height="250" style="position:relative; !important"></canvas>
<script>
var ctx = document.getElementById('myChart<?php echo$person['id'];?>').getContext('2d');
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['<?php echo implode("','", $format); ?>'],
datasets: [{
data: [<?php echo implode(',', $count); ?>],
backgroundColor: ['<?php echo implode("','", $color); ?>'],
hoverOffset: 10
}]
},
options: {
layout: {
padding: {
left: 30,
right: 30,
top: 0
}
},
plugins: {
legend: {
display: false
}
}
}
});
</script>
<?php endif; ?>
<a href="viewer.php?viewer=<?php echo $person['id']; ?>">More Details</a>
</div>
</div>
</div>
<?php endforeach;?>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#movies').DataTable(
{
"searching":false,
"paging": false,
"lengthChange": false,
"order": [[ 1, "desc" ]],
"columnDefs": [
{ "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 11 ] },
]
}
);
} );
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
</script>
<?php template('footer');?>