laravel / nova-issues

554 stars 34 forks source link

Trend metric not using column parameter #95

Closed gdespirito closed 6 years ago

gdespirito commented 6 years ago

I've created a trend Metric, and used the default countByDays methods to aggregate my data, but i configured the third parameter to use a special column date, not the default created_at. image

But for what can i see, that parameter is not used image

rcknr commented 6 years ago

You can override getCreatedAtColumn method on your model for now. Also note that it's the fourth parameter, the third is the column you wanna count.

gdespirito commented 6 years ago

I already fixed it on my app. But this is an easy fix. They just forgot to pass that variable to a function.

On Fri, Aug 24, 2018 at 5:22 AM Sergii Kauk notifications@github.com wrote:

You can override getCreatedAtColumn method on your model for now. Also note that it's the forth parameter, the third is the column you wanna count.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/laravel/nova-issues/issues/95#issuecomment-415689171, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDWhlKDk-wEYwPqwRE_NQFb70i4NfiVks5uT7fHgaJpZM4WKq8P .

-- Enviado con Gmail Mobile

vmitchell85 commented 6 years ago

Solution is presented in #108, but is really a duplicate of this issue.

jringeisen commented 6 years ago

I'm having a similar issue. I'm using Laravel Cashier and I want to display a value card for Cancelled Subscriptions but it's pulling from the created_at instead of the ends_at. I also have a value card that displays Active Subscriptions so overriding the getCreatedAtColumn in my model wouldn't work. Any ideas?

public function calculate(Request $request) { return $this->count($request, Subscription::class, 'ends_at'); }

warren32 commented 6 years ago

@jringeisen the Value metric type currently doesn't support anything other than the created_at column on the model from the looks of it. I believe this original issue was regarding the Trend metric. It would be a great addition as we may want to see how many records their are in a date range other than created at. Like "how many subscriptions where the trial ends this week"

jringeisen commented 6 years ago

@warren32 exactly. And it being an admin panel not sure why this would be left out. I would like to be able to track subscription cancellations but can't. Also, why would they include column in the count method if it only accepts created_at?

taylorotwell commented 6 years ago

Will be fixed in next release.

totiherms commented 4 years ago

Hi, any update on this?

return $this->count($request, Visit::class, 'startDate');

is running the query

select count(startDate) as aggregate from visits where created_at between 2019-10-03 12:30:37 and 2019-11-02 12:30:37)

jbrooksuk commented 4 years ago

@totiherms you're using the wrong parameter:

return $this->count($request, Visit::class, null, 'startDate');
totiherms commented 4 years ago

@totiherms you're using the wrong parameter:

return $this->count($request, Visit::class, null, 'startDate');

thanks!

/**