Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
720 stars 74 forks source link

duration aggregate #29

Closed FrodeMMeling closed 1 year ago

FrodeMMeling commented 1 year ago

Is it possible to aggregate on a duration in minutes between two timestamps. Like using MYSQL TIMESTAMPDIFF

FrodeMMeling commented 1 year ago

I was able to hack this in by doing this: ->aggregate('HOUR, login_time, logout_time)', 'SUM(TIMESTAMPDIFF'); If aggregate function could take more parameters this would work without the ')' hack. A timestamp function may not be added since that is not supported in all databases.

Maybe adding $column parameter as string|array. then if array, you do a implode(",", $columns) to then I think all existing code will not be broken. ->aggregate(['HOUR', 'login_time', 'logout_time']....

Larsklopstra commented 1 year ago

Seems like you've found a workaround.