mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-11 09:42:15 +01:00
Added filled gaps to time entry aggregation; Moved aggregation to service
This commit is contained in:
@@ -11,8 +11,8 @@ use App\Models\Tag;
|
||||
use App\Models\Task;
|
||||
use App\Models\TimeEntry;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends Factory<TimeEntry>
|
||||
@@ -67,11 +67,13 @@ class TimeEntryFactory extends Factory
|
||||
});
|
||||
}
|
||||
|
||||
public function startBetween(Carbon $rangeStart, Carbon $rangeEnd): self
|
||||
public function startBetween(Carbon $rangeStart, Carbon $rangeEnd, bool $fixedValueForMultiple = false): self
|
||||
{
|
||||
$start = Carbon::instance($this->faker->dateTimeBetween($rangeStart, $rangeEnd));
|
||||
$fixedStart = Carbon::instance($this->faker->dateTimeBetween($rangeStart, $rangeEnd));
|
||||
|
||||
return $this->state(function (array $attributes) use ($rangeStart, $rangeEnd, $fixedStart, $fixedValueForMultiple): array {
|
||||
$start = $fixedValueForMultiple ? $fixedStart : Carbon::instance($this->faker->dateTimeBetween($rangeStart, $rangeEnd));
|
||||
|
||||
return $this->state(function (array $attributes) use ($start): array {
|
||||
return [
|
||||
'start' => $start->utc(),
|
||||
'end' => $this->faker->dateTimeBetween($start, 'now'),
|
||||
@@ -111,6 +113,34 @@ class TimeEntryFactory extends Factory
|
||||
});
|
||||
}
|
||||
|
||||
public function billable(): self
|
||||
{
|
||||
return $this->state(function (array $attributes): array {
|
||||
return [
|
||||
'billable' => true,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function startWithDuration(Carbon $start, int $durationInSeconds): self
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($start, $durationInSeconds): array {
|
||||
return [
|
||||
'start' => $start->utc(),
|
||||
'end' => $start->copy()->addSeconds($durationInSeconds),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function start(Carbon $start): self
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($start): array {
|
||||
return [
|
||||
'start' => $start->utc(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function forOrganization(Organization $organization): self
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($organization) {
|
||||
|
||||
Reference in New Issue
Block a user