-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstats.html
751 lines (656 loc) · 31.2 KB
/
stats.html
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arcade Review Stats</title>
<!-- SEO meta tags -->
<meta name="description" content="Track real-time stats updated every 15 minutes for the Hack Club Arcade Review stats.">
<meta name="keywords" content="hack club, hack club arcade, arcade, hack club arcade stats, hack club arcade review stats, arcade review stats">
<!-- Google fonts - Official Arcade fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Slackey&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Gaegu&display=swap" rel="stylesheet">
<link rel="icon" href="favicon.png" type="image/x-icon">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-adapter-moment/1.0.0/chartjs-adapter-moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.43/moment-timezone-with-data.min.js"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZD8ZCNJRQQ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ZD8ZCNJRQQ');
</script>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #fbefd6;
}
.container {
max-width: 750px;
margin: auto;
padding: 20px;
border-radius: 5px;
}
h1 {
text-align: center;
color: #333;
}
p{
text-align: center;
color: #333;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 5px;
text-align: center;
}
th {
background-color: #fbefd6;
border: 0px;
/* font-family: 'Slackey'; */
color: #fb8b3c;
font-weight: bold;
font-size: 1.3rem;
}
#chartContainer {
margin-top: 40px;
height: 400px;
}
.font-1{
font-family: 'Slackey';
color: #fb8b3c;
}
.font-2{
font-family: 'Gaegu';
}
.heading{
font-size: 2.5rem;
margin-bottom: 0px;
}
.description{
font-size: 1.4rem;
text-align: center;
margin: 0px;
}
.description-secondary{
font-size: 1.2rem;
text-align: center;
margin: 0px;
color: grey;
margin-bottom: 30px;
}
/* link */
a{
color: #ef3553;
text-decoration: underline;
text-underline-position: under;
cursor: pointer;
}
a:hover{
color: #ef3553;
text-decoration: underline wavy;
}
.about {
background-color: #fb8b3c;
color: #fbefd6;
padding: 15px;
margin-top: 20px;
border-radius: 5px;
}
.about-listed{
letter-spacing: 0.01px;
font-size: 1.2rem;
}
#statsChart {
font-family: 'Gaegu', cursive;
margin-bottom: 25px;
}
@media (max-width: 416px) {
#statsChart {
margin-bottom: 50px;
}
}
.stats-container {
background-color: #00afb3;
color: #fbefd6;
padding: 15px;
margin-top: 20px;
border-radius: 5px;
text-align: center;
}
.stats-p{
font-size: 1.2rem;
color: #fbefd6;
margin: 0px;
}
.stats-h2{
font-size: 1.5rem;
color: #fbefd6;
margin: 0px;
}
#paginationControls button {
background-color: #00afb3;
color: #fbefd6;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
transition: 0.2s;
}
#paginationControls button:hover {
background-color: #338d8f;
transform: scale(1.05);
}
#paginationControls button:active {
transform: scale(0.95);
}
#paginationControls button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
#paginationControls:hover button:disabled {
transform: scale(1);
}
#paginationControls:active button:disabled {
transform: scale(1);
}
#pageInfo {
font-size: 1rem;
color: #333;
}
#vermontTimeContainer {
margin: 0px;
background-color: #fbefd6;
color: #000000;
padding: 15px;
margin-top: 20px;
border-radius: 5px;
text-align: center;
padding: 0px;
}
#vermontTimeContainer p {
margin: 5px 0;
font-size: 1.2em;
}
.h2status{
font-size: 1.5rem;
color: #fbefd6;
margin: 0px;
}
.status-p{
font-size: 1.2rem;
color: #fbefd6;
margin: 0px;
font-weight: normal;
}
.chart-option{
font-family: 'Gaegu';
background-color: #00afb3;
color: #fbefd6;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
transition: 0.2s;
}
.chart-option:hover{
background-color: #0b9395;
transform: scale(1.04);
}
.chart-option:active{
transform: scale(0.96);
}
.notice{
color: #000000;
font-size: 1.2rem;
padding: 15px;
margin-top: 20px;
border-radius: 10px;
border: 5px dashed #ef3553;
line-height: 30px;
}
/* Buttons */
.btn {
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 1.2rem;
transition: 0.2s;
border: none;
font-family: 'Slackey', cursive;
}
.btn-primary {
background-color: #00afb3;
color: #fbefd6;
}
.btn:hover {
transform: scale(1.05);
}
.btn:active {
transform: scale(0.97);
}
</style>
</head>
<body>
<div class="container">
<h1 class="font-1 heading">Arcade Review Stats</h1>
<!-- <p class="font-2 description">By Hayden Kong. For the <a href="https://hackclub.com/arcade">Hack Club Arcade</a>!</p> -->
<p class="font-2 description-secondary">By Hayden Kong. Get the latest session review stats for <a href="https://hackclub.com/arcade">Arcade</a>! Updated every 5 minutes. Get LIVE results by running /arcadereviewstats in the <a href="https://hackclub.com/slack">Hack Club Slack</a>!</p>
<div class="notice">
<p class="font-2">hey! arcade has ended 🥲🥲 and you won't be able to start new sessions or link sessions to scrapbook posts!
our wonderful reviewing team is currently working on reviewing the backlog, as you can see below!! (its live btw!). if you liked arcade (that should be you),
please leave a thank you note to all the people who made arcade possible by clicking the button below!
</p>
<div style="text-align: center;">
<a href="letter.html"><button class="btn btn-primary">Leave a note!</button></a>
</div>
</div>
<!-- <div class="about" style="background-color: #ef3553;">
<p class="font-2" style="color: #fbefd6; font-size: 1.2rem;"><b>🎉RESOLVED🎉: </b>
Thanks to @cskartikey for fixing the issue! Arcade Review stats should be back up and running :). Currently monitoring for any issues.
</p>
<p class="font-2" style="color: #fbefd6; font-size: 1.2rem;"><b>UPDATE: </b>
It seems like the nest servers are down because the server disk is full. Currently early morning at HQ and awaiting for information.
</p>
<p class="font-2" style="color: #fbefd6; font-size: 1.2rem; "><b>⚠️NOTICE⚠️: </b>
Hack Club Nest servers are currently down. The API that powers the data collection is run on Nest, therefore there is currently a temporary disruption and unavailability to Arcade Review stats. Sorry! - Hayden Kong</p>
</div> -->
<!-- <div class="about" style="background-color: #ef3553;">
<p class="font-2" style="color: #fbefd6; font-size: 1.2rem;"><b>⚠️Outage⚠️: </b>
We are currently experiencing some issues with the information retrival from the official
Arcade Airtable dashboard. We are currently troubleshooting this issue. - Sorry!
(p.s you can try this alternaitve made by <a style="color: #fbefd6" href="https://arcade-tracker.smashcloud.org/">@smashmaster0045</a>)
</p>
</div> -->
<!-- <div class="about" style="background-color: #ef3553;">
<p class="font-2" style="color: #fbefd6; font-size: 1.2rem; "><b>⚠️Scheduled Maintenance Notification⚠️: </b>
Hack Club Nest will be down today around 3:30 am EST/12:30 am PST/9:30 am CEST/1
pm IST for a 1 TB NVMe upgrade. This will affect the Arcade Review Stats API for
about 15-45 minutes. We apologize for any inconvenience and appreciate your
understanding.
</p>
</div> -->
<div class="stats-container font-2" id="reviewStatus">
<!-- review stats here -->
</div>
<div id="chartContainer">
<div id="chartOptions" class="font-2" style="text-align: center; margin-bottom: 10px;">
<button class="chart-option" data-option="max">Max</button>
<button class="chart-option" data-option="5days">Past 5 Days</button>
<button class="chart-option" data-option="3days">Past 3 Days</button>
<button class="chart-option" data-option="24hours">Last 24 Hours</button>
</div>
<canvas id="statsChart"></canvas>
</div>
<!-- <div class="about">
<p class="font-2" style="color: #fbefd6; font-size: 1.2rem;"><b>⚠️NOTICE⚠️: </b>
There is currently a huge backlog and most reviewers are away and on the <a style="color: #fbefd6" href="https://boreal.hackclub.com/">Boreal Express</a>. Please be patient!
Reviewers are mostly volunteers. Sessions are not reviewed in order and take around 2-7 days (or more) to get reviewed.
</p>
</div> -->
<div class="stats-container font-2" id="recentStats">
<!-- recent stats here -->
</div>
<table id="statsTable" class="font-2">
<h2 class="font-1" style="text-align: center; font-size: 2rem; margin-top: 50px; margin-bottom: 0px;">Full Logs</h2>
<div id="vermontTimeContainer">
<!-- Vermont time -->
</div>
<div class="stats-container font-2" id="countdownTimer">
<!-- countdown timer here -->
</div>
<thead>
<tr>
<th>Timestamp</th>
<th>Hours Pending Review</th>
<th>Hours Approved (Past 7 days)</th>
</tr>
</thead>
<tbody id="tableBody">
</tbody>
</table>
<div class="about">
<h3 class="font-1" style="color: #fbefd6; font-size: 1.5rem; margin-bottom: 0px; text-align: center;">How this works</h3>
<ol class="font-2">
<li class="about-listed">Every 15 minutes, a python script hosted using <a style="color: #fbefd6" href="https://guides.hackclub.app/index.php/Main_Page">Hack Club Nest</a> scrapes the Hack Club <a style="color: #fbefd6" href="https://airtable.com/appOKDJk2ALKSisEM/shriBhjoCj83rYCGT">Arcade Review Stats dashboard</a>.</li>
<li class="about-listed">The python script saves the hours pending review and hours reviewed in the past 7 days from the dashboard to a txt file.</li>
<li class="about-listed">Every time you load this page, it calls an <a style="color: #fbefd6" href="apidocs.html">API (click here for docs)</a> which gets the saved txt file from the Nest server containing all the data!</li>
</ol>
</div>
<h2 class="font-1" style="font-size: 2rem; text-align: center;">More info...</h2>
<p class="font-2" style="text-align: center; font-size: 1.2rem;"><b>💡Some extra info about the 7-day total💡</b></p>
<p class="font-2" style="text-align: center; font-size: 1.2rem; margin-top: 0px;">The stat represents a rolling 7-day total, updated daily at 0:00 EDT.
When it updates, it removes data older than 7 days and adds the new day's data. This can cause a noticeable decrease if a high-activity day from 7 days ago is removed from the count. The line will then gradually increase as new approvals are added throughout the day.
</p>
<p class="font-2" style="text-align: center; font-size: 1.2rem;"><b>⌚Time zone⌚</b></p>
<p class="font-2" style="text-align: center; font-size: 1.2rem; margin-top: 0px;">Hack Club Nest's servers are located in Helsinki, Finland. The time zone that is used for the logging and timestamps is in GMT (Greenwich Mean Time). However, the timestamps are converted to your local time zone!
</p>
<p class="font-2" style="text-align: center; font-size: 1.2rem;"><b>🎯Accuracy of the data🎯</b></p>
<p class="font-2" style="text-align: center; font-size: 1.2rem; margin-top: 0px;">All the data scraped is from the official public Arcade Review dashboard. The data is not manipulated in any way and is directly from the dashboard. The accuracy of the data is controlled by Hack Club :)
</p>
<p class="font-2" style="text-align: center;">-------------------</p>
<p class="font-2" style="text-align: center; font-size: 1.2rem;">If you have any suggestions or issues, please <a href="https://forms.fillout.com/t/hSJMTXtGshus">fill out this form</a> or contact me on the Hack Club Slack: @Hayden Kong. <a href="index.html">Go back home</a>.</p>
<p class="font-2" style="font-size: 1.2rem; margin-top: 55px; color: grey;">© 2024 Hayden Kong. All rights reserved.</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const apiUrl = 'statsdata.html';
let allData = [];
const rowsPerPage = 50;
let currentPage = 1;
let totalPages = 0;
let chart;
async function fetchStats() {
try {
const response = await fetch(apiUrl);
const textData = await response.text();
allData = textData.split('\n')
.filter(line => line.trim() !== '')
.map(item => {
const parsedItem = JSON.parse(item);
parsedItem.timestamp = moment.utc(parsedItem.timestamp).local().format('YYYY-MM-DD HH:mm:ss');
return parsedItem;
})
.sort((a, b) => moment(b.timestamp).diff(moment(a.timestamp)));
totalPages = Math.ceil(allData.length / rowsPerPage);
createPaginationControls();
populateTable();
createChart(allData); // Initial chart creation with all data
updateReviewStatus(allData);
updateRecentStats(allData);
updateVermontTime();
updateCountdownTimer(allData[0].timestamp);
} catch (error) {
console.error('Error fetching data:', error);
}
}
function populateTable() {
const tableBody = document.querySelector('#tableBody');
tableBody.innerHTML = ''; // clear existing rows
const startIndex = (currentPage - 1) * rowsPerPage;
const endIndex = startIndex + rowsPerPage;
const pageData = allData.slice(startIndex, endIndex);
pageData.forEach(data => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${data.timestamp}</td>
<td>${data.hours_pending}</td>
<td>${data.hours_approved}</td>
`;
tableBody.appendChild(row);
});
updatePaginationControls();
}
function createPaginationControls() {
const paginationContainer = document.createElement('div');
paginationContainer.id = 'paginationControls';
paginationContainer.className = 'font-2';
paginationContainer.style.textAlign = 'center';
paginationContainer.style.marginTop = '20px';
const backButton = document.createElement('button');
backButton.id = 'backButton';
backButton.innerHTML = '←'; // left arrow
backButton.addEventListener('click', () => changePage(-1));
const pageInfo = document.createElement('span');
pageInfo.id = 'pageInfo';
pageInfo.style.margin = '0 10px';
const forwardButton = document.createElement('button');
forwardButton.id = 'forwardButton';
forwardButton.innerHTML = '→'; // right arrow
forwardButton.addEventListener('click', () => changePage(1));
paginationContainer.appendChild(backButton);
paginationContainer.appendChild(pageInfo);
paginationContainer.appendChild(forwardButton);
document.querySelector('#statsTable').insertAdjacentElement('afterend', paginationContainer);
}
function updatePaginationControls() {
const pageInfo = document.getElementById('pageInfo');
pageInfo.textContent = `Page ${currentPage} of ${totalPages}`;
const backButton = document.getElementById('backButton');
const forwardButton = document.getElementById('forwardButton');
backButton.disabled = currentPage === 1;
forwardButton.disabled = currentPage === totalPages;
}
function changePage(direction) {
currentPage += direction;
currentPage = Math.max(1, Math.min(currentPage, totalPages));
populateTable();
}
function updateVermontTime() {
const vermontTimeContainer = document.createElement('div');
vermontTimeContainer.id = 'vermontTimeContainer';
vermontTimeContainer.className = 'font-2 time-container';
vermontTimeContainer.style.marginTop = '20px';
const vermontTime = moment().tz('America/New_York'); // Vermont is in the Eastern Time Zone
const timeOfDay = getTimeOfDay(vermontTime);
const timeString = vermontTime.format('h:mm A');
const timeElement = document.createElement('p');
timeElement.className = 'time-p';
timeElement.innerHTML = `<strong>Current time in Hack Club HQ:</strong> (${timeString}) ${timeOfDay} `;
vermontTimeContainer.appendChild(timeElement);
document.querySelector('#vermontTimeContainer').insertAdjacentElement('beforebegin', vermontTimeContainer);
}
function getTimeOfDay(time) {
const hour = time.hour();
if (hour >= 5 && hour < 8) {
return 'Early Morning 🍵 - Avoid Pinging!';
} else if (hour >= 8 && hour < 12) {
return 'Morning 🌇 (In Office)';
} else if (hour >= 12 && hour < 13) {
return 'Midday ☀️ (In Office)';
} else if (hour >= 13 && hour < 17) {
return 'Afternoon 🕑 (In Office)';
} else if (hour >= 17 && hour < 20) {
return 'Evening 🌙 (Out of Office)';
} else if (hour >= 20 || hour < 5) {
return 'Night 🛏️💤💤 - Avoid Pinging!';
}
}
function createChart(data) {
const ctx = document.getElementById('statsChart').getContext('2d');
// reverse the data for the chart so it shows oldest to newest left to right
const chartData = [...data].reverse();
const timestamps = chartData.map(item => moment(item.timestamp).toDate());
const pendingData = chartData.map(item => item.hours_pending);
const approvedData = chartData.map(item => item.hours_approved);
Chart.defaults.font.family = "'Gaegu', cursive";
Chart.defaults.font.size = 14;
chart = new Chart(ctx, {
type: 'line',
data: {
labels: timestamps,
datasets: [
{
label: 'Hours Pending Review',
data: pendingData,
borderColor: '#fb8b3c',
tension: 0.1,
pointRadius: 0
},
{
label: 'Hours Approved (Past 7 days)',
data: approvedData,
borderColor: '#00afb3',
tension: 0.1,
pointRadius: 0
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
type: 'time',
time: {
unit: 'hour',
displayFormats: {
hour: 'MMM D, HH:mm'
},
tooltipFormat: 'MMM D, YYYY, HH:mm'
},
title: {
display: true,
text: 'Timestamp (Local Time)',
font: {
weight: 'bold'
}
}
},
y: {
beginAtZero: false,
title: {
display: true,
text: 'Hours',
font: {
weight: 'bold'
}
}
}
},
plugins: {
title: {
display: false,
text: 'Arcade Review Stats Graph',
font: {
weight: 'bold'
}
},
tooltip: {
mode: 'index',
intersect: false,
},
legend: {
labels: {
font: {
family: "'Gaegu', cursive",
weight: 'bold'
}
}
}
},
interaction: {
mode: 'nearest',
axis: 'x',
intersect: false
},
animation: {
duration: 1000, // in ms
easing: 'easeInOutQuart' // easing for smooth animation
}
}
});
}
function updateChartData(option) {
const filteredData = filterDataByOption(allData, option);
const chartData = [...filteredData].reverse();
const timestamps = chartData.map(item => moment(item.timestamp).toDate());
const pendingData = chartData.map(item => item.hours_pending);
const approvedData = chartData.map(item => item.hours_approved);
chart.data.labels = timestamps;
chart.data.datasets[0].data = pendingData;
chart.data.datasets[1].data = approvedData;
chart.update();
}
function updateReviewStatus(dataArray) {
const statusContainer = document.getElementById('reviewStatus');
const latest = dataArray[0];
const previous = dataArray[1];
if (latest.hours_approved > previous.hours_approved) {
statusContainer.innerHTML = '<h2 class="h2status">🎉 Sessions are being reviewed! 🎉</h2>' + '<h2 class="status-p">' + (latest.hours_approved-previous.hours_approved) + ' reviewed in the past 15 minutes!</h2>';
} else {
statusContainer.innerHTML = '<h2 class="h2status">😴 Sessions arent being reviewed right now. Pls be patient!</h2>';
}
}
function updateRecentStats(dataArray) {
const statsContainer = document.getElementById('recentStats');
const latest = dataArray[0];
const thirtyMinutesAgo = dataArray.find(item => {
const timeDiff = moment(latest.timestamp).diff(moment(item.timestamp), 'minutes');
return timeDiff >= 30;
});
if (thirtyMinutesAgo) {
const sessionsReviewed = latest.hours_approved - thirtyMinutesAgo.hours_approved;
const hoursAdded = latest.hours_pending - thirtyMinutesAgo.hours_pending;
statsContainer.innerHTML = `
<h2 class="stats-h2">Last 30 Minutes Stats:</h2>
<p class="stats-p">Sessions Reviewed: ${sessionsReviewed}</p>
<p class="stats-p">Hours Added to Queue: ${hoursAdded}</p>
`;
} else {
statsContainer.innerHTML = '<p>Not enough data for 30-minute stats yet.</p>';
}
}
function updateCountdownTimer(latestTimestamp) {
const countdownContainer = document.getElementById('countdownTimer');
let isLoading = false;
function updateTimer() {
const now = moment();
const latestUpdate = moment(latestTimestamp);
const nextUpdate = latestUpdate.add(5, 'minutes');
const duration = moment.duration(nextUpdate.diff(now));
if (duration.asSeconds() <= 0) {
if (!isLoading) {
// 10-sec loading period
isLoading = true;
countdownContainer.innerHTML = `
<h2 class="stats-h2">GETTING LATEST STATS</h2>
<p class="stats-p">Please wait 10 seconds. This page will auto-refresh.</p>
`;
setTimeout(() => {
location.reload();
}, 10000); // 10 seconds
}
} else {
const minutes = Math.floor(duration.asMinutes());
const seconds = Math.floor(duration.asSeconds() % 60);
countdownContainer.innerHTML = `
<h2 class="stats-h2">Next API Update:</h2>
<p class="stats-p">${minutes} minutes ${seconds} seconds</p>
`;
setTimeout(updateTimer, 1000);
}
}
updateTimer();
}
function filterDataByOption(data, option) {
const now = moment();
switch (option) {
case '5days':
return data.filter(item => moment(item.timestamp).isAfter(now.clone().subtract(5, 'days')));
case '3days':
return data.filter(item => moment(item.timestamp).isAfter(now.clone().subtract(3, 'days')));
case '24hours':
return data.filter(item => moment(item.timestamp).isAfter(now.clone().subtract(24, 'hours')));
default:
return data;
}
}
document.querySelectorAll('.chart-option').forEach(button => {
button.addEventListener('click', () => {
const option = button.getAttribute('data-option');
updateChartData(option);
});
});
fetchStats();
});
</script>
</body>
</html>