<?php

namespace App\Services;

use App\Core\Database;

class StudioMetricsService
{
public static function metrics(
int $orgId,
int $conferenceId
):array
{

$db=
Database::getInstance();

$tables=[

'submissions',
'reviews',
'reviewer_assignments',
'tracks',
'users',
'notifications'

];

$out=[];

foreach($tables as $t){

try{

$q=$db->query(
"SELECT COUNT(*) c
FROM {$t}"
);

$out[$t]=
(int)
$q->fetchColumn();

}catch(\Throwable $e){

$out[$t]=0;

}

}

$out['health']=

min(

100,

round(

array_sum(
$out
)

/

max(
1,
count(
$out
)
)

)

);

return $out;

}

}
