Jump to content

Tenant usage is not updated as expected


Recommended Posts

Hello,

we are currently implementing some metrics, but i can't get the tenant usage to work as i would expect it. 

Click the "refresh" button in the products/services tab on the clients details page. The tenantUsage function is called with the expected tenant (i use a custom field here). But when I populate a metric with a Usage using Metric->withUsage(), the Metric object holds a "NoUsage" Object afterwards.

I tried with different Metrics using different units and periods. I tried explicitly setting the from, to and collectedAt dates when instantiating the Usage. I tried passing different values into the Usage constructor - no success. The tbltenant_stats entry is updated with the new updated_at time, but the value remains 0.000. The table in the admins frontend also reads "-" where i would expect the updated usage values.

Here is some minimal example:

 public function metrics() 
    {
        return [
            new Metric(
                'mymetric',
                'My metric',
                MetricInterface::TYPE_PERIOD_MONTH,
                new KiloBytes()
            )
        ]
    }
    public function tenantUsage($tenant)
    {
        $metric = current($this->metrics());

        $usage = new Usage(123.4); //$usage holds the value as expected

        $populatedMetric = $metric->withUsage($usage); //$populatedMetric now holds an instance of NoUsage 

        $controlUsage = $usageMetric->usage(); //control usage is instanceof NoUsage

        return $usage;
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated