Flowframe / laravel-trend

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

Interval perWeek() #43

Open Amitoj02 opened 9 months ago

Amitoj02 commented 9 months ago

It will be very useful to have perWeek() aggregate interval. Thank you.

vpuentem commented 8 months ago

You can use the interval() method which is used internally by the Trend class, something like this:

Trend::query(Model::class->where('condition', value))
            ->between(
                start: date,
                end: date,
            )
            ->interval('week')
            ->count();

(code not tested but it should work, although correct me if i'm wrong)

image

davidvandertuijn commented 8 months ago

You can use the interval() method which is used internally by the Trend class, something like this:

Trend::query(Model::class->where('condition', value))
            ->between(
                start: date,
                end: date,
            )
            ->interval('week')
            ->count();

(code not tested but it should work, although correct me if i'm wrong)

image

Error: Invalid Interval.

return match ($this->interval) {
    'minute' => 'Y-m-d H:i:00',
    'hour' => 'Y-m-d H:00',
    'day' => 'Y-m-d',
    'month' => 'Y-m',
    'year' => 'Y',
    default => throw new Error('Invalid interval.'),
};
davidvandertuijn commented 8 months ago

It will be very useful to have perQuarter() aggregate interval. Thank you.

Semvrij commented 5 months ago

Any news on this issue?

d8vjork commented 4 months ago

@davidvandertuijn +1 to what you just said, I was just around it

d8vjork commented 4 months ago
image

Ok managed to get around quarters but not without "hacking" into some stuff

Now is whether the author(s) of this package want to mess the "normal" API flow or not (if it was me: I would just release a major)

Note: I didn't manage to make it work within SQLite cause I really don't understand its syntax and I never use it

d8vjork commented 4 months ago

Mentioned here the quarter for those who might be interested: #56