Fixes front page conferences counting

main
Yasen Pramatarov 2024-10-03 19:33:31 +03:00
parent 9c187c9550
commit fbe646823d
4 changed files with 136 additions and 20 deletions

View File

@ -274,25 +274,52 @@ ORDER BY
$until_time = htmlspecialchars(strip_tags($until_time));
// number of conferences for time period (if given)
// NB we need to cross check with first occurrence of "bridge selected"
// as in Jicofo logs there is no way to get the time for conference ID creation
// FIXME sometimes there is no start/end time, find a way around this
$sql = "
SELECT COUNT(c.conference_id) as conferences
FROM
conferences c
LEFT JOIN (
SELECT ce.conference_id, MIN(ce.time) as first_event_time
SELECT COUNT(*) AS conferences
FROM (
SELECT DISTINCT
(SELECT COALESCE
(
(SELECT ce.time
FROM conference_events ce
WHERE ce.conference_event = 'bridge selected'
GROUP BY ce.conference_id
) AS first_event ON c.conference_id = first_event.conference_id
LEFT JOIN
WHERE
ce.conference_id = c.conference_id
AND
ce.conference_event = 'conference created'
),
(SELECT ce.time
FROM conference_events ce
WHERE
ce.conference_id = c.conference_id
AND
ce.conference_event = 'bridge selected'
)
)
) AS start,
(SELECT COALESCE
(
(SELECT ce.time
FROM conference_events ce
WHERE
ce.conference_id = c.conference_id
AND
(ce.conference_event = 'conference expired' OR ce.conference_event = 'conference stopped')
),
(SELECT pe.time
FROM participant_events pe
WHERE
pe.event_param = c.conference_id
ORDER BY pe.time DESC
LIMIT 1
)
)
) AS end
FROM conferences c
JOIN
conference_events ce ON c.conference_id = ce.conference_id
WHERE
(ce.time >= '%s 00:00:00' AND ce.time <= '%s 23:59:59')
AND (ce.conference_event = 'conference created'
OR (ce.conference_event = 'bridge selected' AND ce.time = first_event.first_event_time)
)";
WHERE (start >= '%s 00:00:00' AND end <= '%s 23:59:59')
) AS subquery";
$sql = sprintf($sql, $from_time, $until_time);

View File

@ -15,6 +15,12 @@
if (isset($_REQUEST['event'])) {
$param .= '&event=' . $_REQUEST['event'];
}
if (isset($_REQUEST['from_time'])) {
$param .= '&from_time=' . $_REQUEST['from_time'];
}
if (isset($_REQUEST['until_time'])) {
$param .= '&until_time=' . $_REQUEST['until_time'];
}
$max_visible_pages = 10;
$step_pages = 10;

View File

@ -9,8 +9,12 @@ $db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform
include '../app/helpers/time_range.php';
// conference id/name are specified when searching specific conference(s)
// either id OR name, id has precedence
// we use $_REQUEST, so that both links and forms work
// if it's there, but empty, we make it same as the field name; otherwise assign the value
//$conferenceName = !empty($_REQUEST['name']) ? "'" . $_REQUEST['name'] . "'" : 'conference_name';
//$conferenceId = !empty($_REQUEST['id']) ? "'" . $_REQUEST['id'] . "'" : 'conference_id';
if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
$conferenceId = $_REQUEST['id'];
unset($_REQUEST['name']);
@ -140,6 +144,6 @@ if (!empty($conferences['records'])) {
}
// display the widget
include '../app/templates/widget.php';
include '../app/templates/event-list-conferences.php';
?>

View File

@ -0,0 +1,79 @@
<div class="row">
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
<!-- Results filter -->
<div class="card w-auto bg-light border-light card-body text-right" style="text-align: right;">
<form method="POST" id="filter_form" action="?platform=<?= $platform_id?>&page=<?= $page ?>">
<label for="from_time">from</label>
<input type="date" id="from_time" name="from_time"<?php if (isset($_REQUEST['from_time'])) echo " value=\"" . $_REQUEST['from_time'] . "\"" ?> />
<label for="until_time">until</label>
<input type="date" id="until_time" name="until_time"<?php if (isset($_REQUEST['until_time'])) echo " value=\"" . $_REQUEST['until_time'] . "\"" ?> />
<input type="text" name="id" placeholder="conference ID"<?php if (isset($_REQUEST['id'])) echo " value=\"" . $_REQUEST['id'] . "\"" ?> />
<input type="text" name="name" placeholder="conference name"<?php if (isset($_REQUEST['name'])) echo " value=\"" . $_REQUEST['name'] . "\"" ?> />
<input type="button" onclick="clearFilter()" value="clear" />
<input type="submit" value="search" />
</form>
<script>
function clearFilter() {
document.getElementById("filter_form").reset();
const filterFields = document.querySelectorAll("#filter_form input");
filterFields.forEach(input => {
if (input.type === 'text' ||input.type === 'date') {
input.value = '';
}
});
}
</script>
</div>
<!-- /Results filter -->
</div>
<!-- widget "<?= $widget['name']; ?>" -->
<div class="collapse show" id="collapse<?= $widget['name'] ?>">
<?php if ($time_range_specified) { ?>
<p class="m-3">time period: <strong><?= $from_time ?> - <?= $until_time ?></strong></p>
<?php } ?>
<div class="mb-5">
<?php if ($widget['full'] === true) { ?>
<table class="table table-striped table-hover table-bordered">
<thead class="thead-dark">
<tr>
<?php foreach ($widget['table_headers'] as $header) { ?>
<th scope="col"><?= htmlspecialchars($header) ?></th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach ($widget['table_records'] as $row) { ?>
<tr>
<?php foreach ($row as $key => $column) {
if ($key === 'conference ID' && isset($conferenceId) && $conferenceId === $column) { ?>
<td><strong><?= htmlspecialchars($column ?? '') ?></strong></td>
<?php } elseif ($key === 'conference ID') { ?>
<td><a href="<?= $app_root ?>?platform=<?= $platform_id?>&page=conferences&id=<?= htmlspecialchars($column ?? '') ?>"><?= htmlspecialchars($column ?? '') ?></a></td>
<?php } elseif ($key === 'conference name' && isset($conferenceName) && $conferenceName === $column) { ?>
<td><strong><?= htmlspecialchars($column ?? '') ?></strong></td>
<?php } elseif ($key === 'conference name') { ?>
<td><a href="<?= $app_root ?>?platform=<?= $platform_id?>&page=conferences&name=<?= htmlspecialchars($column ?? '') ?>"><?= htmlspecialchars($column ?? '') ?></a></td>
<?php } else { ?>
<td><?= htmlspecialchars($column ?? '') ?></td>
<?php }
} ?>
</tr>
<?php } ?>
</tbody>
</table>
<?php
if ($widget['pagination'] && $item_count > $items_per_page) {
$url = "$app_root?platform=$platform_id&page=$page";
include '../app/helpers/pagination.php';
}
?>
<?php } else { ?>
<p class="m-3">No matching records found.</p>
<?php } ?>
</div>
</div>
<!-- /widget "<?= $widget['name']; ?>" -->