fix: [internal] Undefined logarithmic key in OrgEventsWidget

pull/9715/head
Jakub Onderka 2024-04-26 13:16:51 +02:00
parent 3d3a207d4d
commit d6283c92c6
1 changed files with 18 additions and 20 deletions

View File

@ -1,7 +1,6 @@
<?php <?php
/** /**
* Org Events widget which reportes the number of events created monthly by each local organizations * Org Events widget which reportes the number of events created monthly by each local organizations
*
*/ */
class OrgEventsWidget class OrgEventsWidget
{ {
@ -25,15 +24,12 @@ class OrgEventsWidget
"logarithmic": "true" "logarithmic": "true"
}'; }';
/* /*
* Target_month must be from 1 to 12 * Target_month must be from 1 to 12
* Target year must be 4 digits * Target year must be 4 digits
*/ */
private function org_events_count($user, $org, $target_month, $target_year) { private function org_events_count($user, $org, $target_month, $target_year)
{
$events_count = 0; $events_count = 0;
$start_date = $target_year.'-'.$target_month.'-01'; $start_date = $target_year.'-'.$target_month.'-01';
@ -57,7 +53,8 @@ class OrgEventsWidget
return $events_count; return $events_count;
} }
private function filter_ghost_orgs(&$data, $orgs){ private function filter_ghost_orgs(&$data, $orgs)
{
foreach ($data['data'] as &$item) { foreach ($data['data'] as &$item) {
foreach(array_keys($orgs) as $org_name) { foreach(array_keys($orgs) as $org_name) {
unset($item[$org_name]); unset($item[$org_name]);
@ -89,6 +86,7 @@ class OrgEventsWidget
} }
$offset++; $offset++;
} }
$logarithmic = isset($options['logarithmic']) && ($options['logarithmic'] === "true" || $options['logarithmic'] === "1");
$data = array(); $data = array();
$data['data'] = array(); $data['data'] = array();
for ($i=0; $i < $limit; $i++) { for ($i=0; $i < $limit; $i++) {
@ -102,9 +100,9 @@ class OrgEventsWidget
$item['date'] = $target_year.'-'.$target_month.'-01'; $item['date'] = $target_year.'-'.$target_month.'-01';
foreach($orgs as $org) { foreach($orgs as $org) {
$count = $this->org_events_count($user, $org, $target_month, $target_year); $count = $this->org_events_count($user, $org, $target_month, $target_year);
if($options['logarithmic'] === "true" || $options['logarithmic'] === "1") { if ($logarithmic) {
$item[$org['Organisation']['name']] = (int) round(log($count, 1.1)); // taking the logarithmic view $item[$org['Organisation']['name']] = (int) round(log($count, 1.1)); // taking the logarithmic view
} else if(empty($options['logarithmic']) || $options['logarithmic'] === "true" || $options['logarithmic'] === "1"){ } else {
$item[$org['Organisation']['name']] = $count; $item[$org['Organisation']['name']] = $count;
} }
// if a positive score is detected at least once it's enough to be // if a positive score is detected at least once it's enough to be