fix devops error

This commit is contained in:
ludo
2024-01-05 01:30:46 +01:00
parent d33dd6e755
commit 25b8fc40c5
128 changed files with 410 additions and 2580 deletions

View File

@@ -42,7 +42,7 @@ class Stat
public static function getStatsbyMultiVar($var, $var_option = '')
{
if (empty($var_option)) {
if ($var_option) {
$var_option = $var;
}
$options = self::getOption($var_option);
@@ -52,39 +52,34 @@ class Stat
public static function getCountByPeriod($var, $begin, $end)
{
$count = self::getModel()
return self::getModel()
->whereBetween($var, $begin, $end)
->count();
return $count;
}
public static function getCountbyVar($var)
{
$db = self::getInstance()->app->db;
$data = self::getModel()
->select($db::raw("count(id) as y, $var as name"))
return self::getModel()
->select($db::raw("count(id) as y, {$var} as name"))
->groupBy($var)
->get();
// var_Debug::message($data);
return $data;
}
public static function getStatsbyOptions($var, $var_option = '')
{
if (empty($var_option)) {
if ($var_option ?? false) {
$var_option = $var;
}
$options = self::getInstance()->controller->getOption($var_option);
$nb = self::getCountbyOption($var);
// var_Debug::message($nb);
$data = [];
foreach ($options as $key => $value) {
$y = (int) $nb[$key];
$data[] = ['y' => $y, 'name' => $value];
}
// var_Debug::message($data);
return $data;
}
@@ -108,6 +103,7 @@ class Stat
public static function getStatsbyMultiOptions($var, $options)
{
$data = [];
foreach ($options as $key => $value) {
$nb = self::getCountbyBin($var, $key);
$data[] = ['y' => $nb, 'name' => $value];
@@ -119,11 +115,8 @@ class Stat
public static function getCountbyBin($var, $value)
{
$bit = pow(2, $value);
$count = self::getModel()
->where($var, '&', $bit)
->count();
return $count;
return self::getModel()->where($var, '&', $bit)->count();
}
public static function getStatsbyPeriod($begin = '', $end = '', $period = 'days')