0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-05-12 04:31:59 +00:00

code cleanup

This commit is contained in:
Kevin Papst 2024-11-24 23:13:47 +01:00
parent 45ba88b5c9
commit 901fab4759
3 changed files with 6 additions and 26 deletions

View file

@ -938,29 +938,6 @@ class TimesheetRepository extends EntityRepository
$query->setFetchMode(Timesheet::class, 'project', ClassMetadata::FETCH_EAGER);
$query->setFetchMode(Timesheet::class, 'user', ClassMetadata::FETCH_EAGER);
/*
// not yet supported by Doctrine
$query->setFetchMode(Project::class, 'customer', ClassMetadata::FETCH_EAGER);
if ($timesheetQuery !== null) {
if ($timesheetQuery->hasQueryHint(TimesheetQueryHint::ACTIVITY_META_FIELDS)) {
$query->setFetchMode(Activity::class, 'meta', ClassMetadata::FETCH_EAGER);
}
if ($timesheetQuery->hasQueryHint(TimesheetQueryHint::PROJECT_META_FIELDS)) {
$query->setFetchMode(Project::class, 'meta', ClassMetadata::FETCH_EAGER);
}
if ($timesheetQuery->hasQueryHint(TimesheetQueryHint::CUSTOMER_META_FIELDS)) {
$query->setFetchMode(Customer::class, 'meta', ClassMetadata::FETCH_EAGER);
}
if ($timesheetQuery->hasQueryHint(TimesheetQueryHint::USER_PREFERENCES)) {
$query->setFetchMode(User::class, 'preferences', ClassMetadata::FETCH_EAGER);
}
}
// ManyToMany not supported by Doctrine yet
// $query->setFetchMode(Timesheet::class, 'tags', ClassMetadata::FETCH_EAGER);
*/
return $query;
}
}

View file

@ -89,15 +89,15 @@ final class WorkingTimeService
public function isApproved(User $user, \DateTimeInterface $dateTime): bool
{
$latestApproval = $this->getLatestApprovalDate($user);
if ($latestApproval === null) {
$latestApprovalDate = $this->getLatestApprovalDate($user);
if ($latestApprovalDate === null) {
return false;
}
$begin = \DateTimeImmutable::createFromInterface($dateTime);
$begin = $begin->setTime(0, 0, 0);
if ($begin > $latestApproval) {
if ($begin > $latestApprovalDate) {
return false;
}

View file

@ -37,6 +37,9 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest
$result = $repository->getPagerfantaForQuery($query);
$this->assertInstanceOf(Pagination::class, $result);
self::assertFalse($query->hasQueryHint(TimesheetQueryHint::CUSTOMER_META_FIELDS));
self::assertFalse($query->hasQueryHint(TimesheetQueryHint::PROJECT_META_FIELDS));
self::assertFalse($query->hasQueryHint(TimesheetQueryHint::ACTIVITY_META_FIELDS));
$result = $repository->getTimesheetsForQuery($query, true);