feat(time-tracking) : add ActiveTimeEntryProvider, fixtures, and serialization groups

- ActiveTimeEntryProvider returns active timer for current user
- TimeEntry fixtures with 10 sample entries for the SIRH project
- Add time_entry:read group to Project, User, and TaskType for embedded serialization

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 22:22:34 +01:00
parent fa0adfde88
commit 1e07eb1d64
5 changed files with 73 additions and 8 deletions

View File

@@ -12,7 +12,10 @@ use App\Entity\TaskGroup;
use App\Entity\TaskPriority;
use App\Entity\TaskStatus;
use App\Entity\TaskType;
use App\Entity\TimeEntry;
use App\Entity\User;
use DateTimeImmutable;
use DateTimeZone;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
@@ -250,6 +253,35 @@ class AppFixtures extends Fixture
$task6->addType($typeAuth);
$manager->persist($task6);
// --- Time Entries (SIRH project, admin user) ---
$timeEntryData = [
['title' => 'Réunion', 'project' => $projectSirh, 'type' => $typeAuth, 'start' => '09:00', 'stop' => '09:45', 'day' => 1],
['title' => 'Page accueil', 'project' => $projectSirh, 'type' => $typePassword, 'start' => '10:00', 'stop' => '12:00', 'day' => 0],
['title' => 'Design admin', 'project' => $projectSirh, 'type' => $typeAuth, 'start' => '09:30', 'stop' => '11:00', 'day' => 2],
['title' => 'Page accueil', 'project' => $projectSirh, 'type' => $typePassword, 'start' => '10:30', 'stop' => '12:15', 'day' => 1],
['title' => 'System os', 'project' => $projectSirh, 'type' => $typeCalendar, 'start' => '13:00', 'stop' => '15:30', 'day' => 0],
['title' => 'Login', 'project' => $projectSirh, 'type' => $typePassword, 'start' => '13:00', 'stop' => '15:00', 'day' => 1],
['title' => 'Script vault', 'project' => $projectSirh, 'type' => $typeCalendar, 'start' => '10:00', 'stop' => '12:00', 'day' => 3],
['title' => 'Script backup BDD', 'project' => $projectSirh, 'type' => $typeAuth, 'start' => '13:30', 'stop' => '15:00', 'day' => 3],
['title' => 'Maquette', 'project' => $projectSirh, 'type' => null, 'start' => '09:00', 'stop' => '11:00', 'day' => 4],
['title' => 'PC compta', 'project' => $projectSirh, 'type' => null, 'start' => '13:30', 'stop' => '15:30', 'day' => 4],
];
$monday = new DateTimeImmutable('monday this week', new DateTimeZone('UTC'));
foreach ($timeEntryData as $data) {
$entry = new TimeEntry();
$entry->setTitle($data['title']);
$entry->setUser($admin);
$entry->setProject($data['project']);
$entry->setStartedAt($monday->modify("+{$data['day']} days")->modify($data['start']));
$entry->setStoppedAt($monday->modify("+{$data['day']} days")->modify($data['stop']));
if ($data['type']) {
$entry->addType($data['type']);
}
$manager->persist($entry);
}
$manager->flush();
}
}