MetaMagik Analytic Controller

Hi, I’m using Kanboard with MetaMagik plugin, i was trying add date filters to Task Distribution but I see that there are a controller and template doing this. But it does not work.


When I press execute nothing appears.

The problem is that missing some configuration or missing some programming?

I havent updated any of my plugins for quite awhile, so its plausible the codes broken in newer kb versions.

Not saying it is, just saying it possible.

And if i had to guess that break would be February of 2021, so kb version 1.2.22 and above might not work. 1.2.21 or below should.

All that, and i just tested it.

Works fine in the latest kanboard. Definitely not broken.

Read this entire thread so you understand what it does and how it works:

Excuse me, you answered me in github also, and I put that my plugin version was 1.2.2, but I was wrong, this was the version of kanboard. My version of MetaMagik is 1.5.5

I figured that.

Doesnt matter.

I tested it. There is no issue. Works as intented.

For me it does not work, I don’t know why. I have not change any file…

Granted, “Works as intended” does not mean “Works how you expect it to”

If you believe it is not working, then you need to understand what the intent was.

The date range filter is for “Creation” date.
The analytic “Sums” all the fields, and then graphs all the values of each Sum.
It only uses fields that are of type “Number”

So either, you have no tasks within your date range, or you have no fields to sum.

I also know this is not truthful. getLastIdentifier is a non existing code within KB.

I doubt this code is your issue, but, i cant rule it out. ALL plugins rely on kb native code to be unmolested.

Yes, of course I change files but unrelated with analytics, or so I thought. The getLastIdentifier is an added function in a TaskMetadataModel.

I see in the following code the variable field_total is 0, in my case not enter in the conditional if (!empty($this->taskMetadataModel->get($task[‘id’], $field[‘human_name’], ‘’)) && $field[‘data_type’] === ‘number’ ), so $metrics is empty probably.

    public function build_range($project_id, $from, $to)
    {
        $metrics = array();
        $total = 0;
        $fields = $this->metadataTypeModel->getAllInScope($project_id);
        
        $newfrom = $this->dateParser->getTimestamp($from." 00:00");
        $newto = $this->dateParser->getTimestamp($to." 23:59");
        
        $tasks = $this->getTasks($project_id, $newfrom, $newto);

        foreach ($fields as $field) {
            
        $field_total = 0;
            
            foreach ($tasks as $task) {
                if (!empty($this->taskMetadataModel->get($task['id'], $field['human_name'], '')) && $field['data_type'] === 'number' ) {
                    $field_total += $this->taskMetadataModel->get($task['id'], $field['human_name'], '');
                    $total += $this->taskMetadataModel->get($task['id'], $field['human_name'], '');
                }

            }
            
            if ($field_total !== 0) {
                $metrics[] = array(
                    'column_title' => $field['human_name'],
                    'nb_tasks' => $field_total,
                    'append' => $field['options'],
                );
            }
            
        }

        if ($total === 0) {
            return array();
        }

        foreach ($metrics as &$metric) {
            $metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
        }

        return $metrics;
    }

Finally, I got it. I had to change the loop