Statistik nur wenn Treffen auch stattgefunden hat
This commit is contained in:
25
stats.php
25
stats.php
@@ -11,6 +11,7 @@ $sql_colors = "
|
||||
COUNT(m.id) AS meeting_count
|
||||
FROM meetings m
|
||||
JOIN colors c ON m.color_id = c.id
|
||||
WHERE m.is_completed = 1
|
||||
GROUP BY c.name, c.hex_code
|
||||
ORDER BY meeting_count DESC
|
||||
";
|
||||
@@ -27,7 +28,8 @@ $sql_participation = "
|
||||
COUNT(mt.user_id) AS total_attendance
|
||||
FROM meeting_teilnehmer mt
|
||||
JOIN users u ON mt.user_id = u.id
|
||||
WHERE mt.attended = 1
|
||||
JOIN meetings m ON mt.meeting_id = m.id
|
||||
WHERE mt.attended = 1 AND m.is_completed = 1
|
||||
GROUP BY u.username
|
||||
ORDER BY total_attendance DESC
|
||||
";
|
||||
@@ -41,10 +43,11 @@ $avg_attendance = 0;
|
||||
$sql_avg_attendance = "
|
||||
SELECT AVG(attended_count) AS avg_attended
|
||||
FROM (
|
||||
SELECT COUNT(user_id) AS attended_count
|
||||
FROM meeting_teilnehmer
|
||||
WHERE attended = 1
|
||||
GROUP BY meeting_id
|
||||
SELECT COUNT(mt.user_id) AS attended_count
|
||||
FROM meeting_teilnehmer mt
|
||||
JOIN meetings m ON mt.meeting_id = m.id
|
||||
WHERE mt.attended = 1 AND m.is_completed = 1
|
||||
GROUP BY mt.meeting_id
|
||||
) AS subquery";
|
||||
$result_avg = mysqli_query($conn, $sql_avg_attendance);
|
||||
if ($row = mysqli_fetch_assoc($result_avg)) {
|
||||
@@ -56,10 +59,11 @@ $avg_wore_color = 0;
|
||||
$sql_avg_wore_color = "
|
||||
SELECT AVG(wore_color_count) AS avg_wore_color
|
||||
FROM (
|
||||
SELECT COUNT(user_id) AS wore_color_count
|
||||
FROM meeting_teilnehmer
|
||||
WHERE wore_color = 1
|
||||
GROUP BY meeting_id
|
||||
SELECT COUNT(mt.user_id) AS wore_color_count
|
||||
FROM meeting_teilnehmer mt
|
||||
JOIN meetings m ON mt.meeting_id = m.id
|
||||
WHERE mt.wore_color = 1 AND m.is_completed = 1
|
||||
GROUP BY mt.meeting_id
|
||||
) AS subquery";
|
||||
$result_avg_wore = mysqli_query($conn, $sql_avg_wore_color);
|
||||
if ($row = mysqli_fetch_assoc($result_avg_wore)) {
|
||||
@@ -74,7 +78,8 @@ $sql_wore_color = "
|
||||
COUNT(mt.user_id) AS wore_color_count
|
||||
FROM meeting_teilnehmer mt
|
||||
JOIN users u ON mt.user_id = u.id
|
||||
WHERE mt.wore_color = 1
|
||||
JOIN meetings m ON mt.meeting_id = m.id
|
||||
WHERE mt.wore_color = 1 AND m.is_completed = 1
|
||||
GROUP BY u.username
|
||||
ORDER BY wore_color_count DESC
|
||||
";
|
||||
|
||||
Reference in New Issue
Block a user