Skip to content
Snippets Groups Projects
Commit 154a6429 authored by David Siegfried's avatar David Siegfried
Browse files

add stats

parent a49684af
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ class GreenlightConnection
$config = Config::Get()->GREENLIGHT_CONNECTION;
if (!$config) {
throw new Exception('POS connection is not configured');
throw new Exception('Greenlight-Connection is not configured');
}
return self::$instance = new self(
......@@ -69,4 +69,15 @@ class GreenlightConnection
$stm->execute();
return $stm->fetchColumn();
}
public function getMeetingData($meeting_id)
{
$sql = "SELECT * FROM rooms as r
JOIN users as u ON u.id = r.user_id
WHERE r.bbb_id = :meeting_id";
$stm = $this->connection->prepare($sql);
$stm->execute([':meeting_id' => $meeting_id]);
return $stm->fetch(PDO::FETCH_ASSOC);
}
}
\ No newline at end of file
......@@ -13,6 +13,8 @@ class StatisticsController extends Controller
{
parent::before_filter($action, $args);
Metric::collect();
$this->buildSidebar();
}
public function index_action()
......@@ -30,6 +32,14 @@ class StatisticsController extends Controller
$this->biggest_meetings = Metric::getStatistics('current_month', 'all', 10);
}
public function export_csv_action()
{
$results = Metric::getExport();
$this->render_csv(
$results,
'BigBlueButtonStatistik_' . time() . '.csv'
);
}
public function buildDataSet($label, $data, $border_color, $background_color)
{
......@@ -62,4 +72,15 @@ class StatisticsController extends Controller
'brown' => 'rgba(255, 159, 64, 1)'];
return $colors[$color];
}
private function buildSidebar()
{
$exports = new ExportWidget();
$exports->addLink(
_('Als CSV herunterladen'),
$this->url_for('statistic/export_csv'),
Icon::create('file-excel')
);
Sidebar::Get()->addWidget($exports);
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ namespace Vec\BBB;
use SimpleORMap;
use DateTime;
use PluginEngine;
use DBManager;
use SimpleORMapCollection;
......@@ -21,7 +22,7 @@ class Metric extends SimpleORMap
$config['belongs_to']['server'] = [
'class_name' => 'Vec\\BBB\\Server',
'assoc_foreign_key' => 'server_id',
'foreign_key' => 'server_id',
];
parent::configure($config);
}
......@@ -31,6 +32,62 @@ class Metric extends SimpleORMap
return DBManager::get()->fetchColumn('SELECT DISTINCT YEAR(`start_time`) FROM `bigbluebutton_metrics`');
}
public static function getExport()
{
$metrics = self::findBySQL('1 ORDER BY `mkdate`');
$results = [];
if(!empty($metrics)) {
$results[] = [
'Server',
'Meeting-id',
'Meeting-Name',
'Anzahl TeilnehmerInnen',
'Anzahl Webcams',
'Anzahl ZuhörerInnen',
'Anzahl Audio',
'BreakOutRaum',
'Start-Zeit',
'End-Zeit',
'Username',
];
$meeting_plugin_installed = PluginEngine::getPlugin('MeetingPlugin') !== null;
foreach($metrics as $metric) {
$result = [];
$result['server'] = $metric->server->url;
$result['meeting_id'] = $metric->meeting_id;
$result['meeting_name'] = $metric->meeting_name;
$result['participant_count'] = $metric->participant_count;
$result['video_count'] = $metric->video_count;
$result['listener_count'] = $metric->listener_count;
$result['voice_participant_count'] = $metric->voice_participant_count;
$result['is_break_out'] = $metric->is_break_out;
$result['start_time'] = $metric->start_time;
$result['end_time'] = $metric->end_time;
$result['email'] = "";
if($meeting_plugin_installed) {
$username = DBManager::get()->fetchColumn(
"SELECT a.username FROM auth_user_md5 a
JOIN vc_meetings vc ON vc.user_id = a.user_id
WHERE vc.remote_id = ?",
[$metric->meeting_id]
);
if($username) {
$result['email'] = $username;
}
} else {
$meeting_data = GreenlightConnection::Get()->getMeetingData($metric->meeting_id);
if($meeting_data) {
$result['email'] = $meeting_data['username'];
}
}
$results[] = $result;
}
return $results;
}
return $results;
}
public static function collect()
{
$servers = SimpleORMapCollection::createFromArray(
......@@ -98,9 +155,9 @@ class Metric extends SimpleORMap
return $msgs;
}
public static function getStatistics($filter = '',$mode = 'sum', $limit = null)
public static function getStatistics($filter = '', $mode = 'sum', $limit = null)
{
if($mode === 'sum') {
if ($mode === 'sum') {
$sql = 'SELECT
COUNT(*) as "Anzahl Konferenzen",
SUM(participant_count) as "Anzahl TeilnehmerInnen",
......@@ -117,7 +174,7 @@ class Metric extends SimpleORMap
$attributes = [];
if ($filter !== '') {
$result =self::getFilter($filter);
$result = self::getFilter($filter);
[$begin, $end] = $result;
}
......@@ -128,11 +185,11 @@ class Metric extends SimpleORMap
}
$sql .= ' ORDER BY `participant_count` DESC, `meeting_name`';
if($limit !== null) {
if ($limit !== null) {
$sql .= " LIMIT {$limit}";
}
if($mode !== 'sum') {
return \DBManager::get()->fetchAll($sql, $attributes);
if ($mode !== 'sum') {
return \DBManager::get()->fetchAll($sql, $attributes);
}
return \DBManager::get()->fetchOne($sql, $attributes);
}
......
pluginname=SimpleBBB-Connector
pluginclassname=SimpleBBBConnector
origin=Vec
version=1.2.0
version=1.2.1
studipMinVersion=4.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment