Feature Request: Create protected method for query generation in Trend metrics #5204
Unanswered
bkuhl
asked this question in
Ideas & Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Scenario
I have a large application with a sizeable data set and calculating metrics in runtime isn't possible. As a new Nova User, I'm also bringing a large data set of pre-calculated metrics in an already established table. We have queue jobs that run daily in the background creating daily "snapshots" of what the counts are at that time, creating DB records like:
This makes it much less expensive to calculate metrics over large periods of time.
The Ask
I'd like to show these as a Trend using the pre-calculated table for weekly, monthly and daily timeframes. This is doable, but the challenge is around the
Laravel\Nova\Metrics\Trend::aggregate(...)method. It'd be great if instead of the query being built in this method, it could be built in anotherprotectedmethod so that it's easier to supply my own query that provides the same database results.My Workaround
At the moment, to meet my needs I've had to mostly duplicate
Laravel\Nova\Metrics\Trend::aggregate(...)so I can still get the benefits offormatAggregateResultDate()andformatPossibleAggregateResultDate()which handle generating the date ranges and ensuring zeroes for records which aren't in the db result set.The result looks something like below (this is all still WIP):
Beta Was this translation helpful? Give feedback.
All reactions