48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
include_once '../objects/stats_user_in_session_row.php';
|
|
|
|
class UserGlobalStats
|
|
{
|
|
public int $nbSessions = 0;
|
|
public float $totalDuration = 0.0;
|
|
|
|
public string $firstSession = "";
|
|
public string $lastSession = "";
|
|
|
|
public UserStatsInSessionRow $totals;
|
|
|
|
public $sessionDebriefRows = array();
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
public function __construct ()
|
|
{
|
|
$this->totals = new UserStatsInSessionRow();
|
|
$this->sessionDebriefRows = array();
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
public function setSessionTotals (array $row)
|
|
{
|
|
$this->nbSessions = (int)$row['NbSessions'];
|
|
$this->totalDuration = (float)$row['TotalDuration'];
|
|
$this->firstSession = $row['MinDate'];
|
|
$this->lastSession = $row['MaxDate'];
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
public function toArray () : array
|
|
{
|
|
return array (
|
|
"nbSessions" => (int)$this->nbSessions,
|
|
"totalDuration" => (float)$this->totalDuration ?? 0.0,
|
|
"firstSessionAsString" => $this->firstSession ?? "",
|
|
"lastSessionAsString" => $this->lastSession ?? "",
|
|
"totals" => $this->totals->toArray(),
|
|
"sessionDebriefRows" => $this->sessionDebriefRows
|
|
);
|
|
}
|
|
}
|
|
?>
|