Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeLog : TimeLogService, cleanup, refactoring #705

Merged
merged 5 commits into from
Jan 21, 2023

Conversation

raphodn
Copy link
Member

@raphodn raphodn commented Jan 16, 2023

J'ai commencé à regarder le fonctionnement de TimeLog (lié à #704)

  • création d'un TimeLogService pour y bouger des fonctions réutilisables (pour l'instant seulement initShiftLog & initCycleBeginningLog)
  • dans ShiftController.freeShiftAction gérer le cas d'un ShiftInvalidatedEvent en plus de ShiftFreedEvent
  • dans Shift.php : utilise setWasCarriedOut()

@raphodn raphodn requested a review from petitalb January 16, 2023 23:24
@raphodn raphodn self-assigned this Jan 17, 2023
$log->setTime($shift->getDuration());
$log->setShift($shift);
$log->setType(TimeLog::TYPE_SHIFT);
$log->setCreatedAt($shift->getStart());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi mettre le createdAt à la date du créneau ? Ca veut dire que tu peux créer des timelog dans le passé. Je ne suis pas sur que c'est ce qu'on veut. Ca va être très compliqué à gérer si il faut des créneaux sont validés dans des cycles antérieurs.

Pour moi, il faut mettre le timelog à la date où il est vraiment créé.

Copy link
Member Author

@raphodn raphodn Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je n'ai pas modifié le code existant, c'est une PR de refactoring
cf TimeLogEventListener.php#L161 & InitTimeLogCommand.php & FixTimeLogCommand.php#L51

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai corrigé

Copy link
Member Author

@raphodn raphodn Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok faut qu'on en discute avant de merger, ca me semble casser la logique actuelle dans le cas d'épiceries qui n'utilisent pas use_card_reader_to_validate_shifts :

  1. ShiftController > bookShiftAction > new ShiftBookedEvent()
  2. TimeLogEventListener > onShiftBooked
  3. createShiftLog

avec tes modifs ca va mettre le createdAt à la date du booking et non à la date du shift
si je book un shift pour le cycle suivant, le TimeLog le comptabilisera au cycle actuel 🤔

Copy link
Member Author

@raphodn raphodn Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

du coup la date devrait pouvoir être définie (et now() si vide

edit : on en a discuté, je revert pour gérer les 2 cas

$log->setType(TimeLog::TYPE_CYCLE_END);
if ($date) {
$log->setCreatedAt($date);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La encore ce n'est pas à nous de mettre la date, il faut laisser symfony mettre la date courante.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem réponse

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai corrigé

@raphodn raphodn force-pushed the raphodn/shift-timelog-cleanup branch from 7f4d320 to 7806982 Compare January 20, 2023 09:08
@raphodn raphodn force-pushed the raphodn/shift-timelog-cleanup branch from 13a6184 to b73e1e2 Compare January 20, 2023 10:15
@raphodn raphodn merged commit d4c4fb9 into master Jan 21, 2023
@raphodn raphodn deleted the raphodn/shift-timelog-cleanup branch January 21, 2023 20:26
quot17 pushed a commit to quot17/gestion-compte that referenced this pull request Mar 28, 2023
* Clarify shift free action

* Create TimeLogService. Refactor createShiftLog & initCycleBeginningLog

* Fix date & description init

* Fix PHPStan errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants