Open alexsmirnovdotcom opened 4 months ago
This issue can be easily resolved by extending Trend
class, overriding getCarbonDateFormat
function and using the new class instead.
class TrendX extends \Flowframe\Trend\Trend
{
protected function getCarbonDateFormat(): string
{
if($this->interval == 'hour') {
return 'Y-m-d H:00:00';
}
return parent::getCarbonDateFormat();
}
}
// Usage
TrendX::model(User::class)->between(...)->perHour()->count()
PgsqlAdapter for query in 'hour' interval get 'YYYY-MM-DD HH24:00:00' format. But CarbonDateFormat for 'hour' interval get 'Y-m-d H:00'. This is get a duplicated empty TrendValue`s because from database receives with seconds, and generate stubs without.