Commit 31701913 authored by François-Xavier Lebastard's avatar François-Xavier Lebastard
Browse files

UNOTOPLYS-44 fix(user action) : la durée n'était pas tracée dans la table des actions utilisateurs

parent 51c8645c
......@@ -112,10 +112,8 @@ public class UserActionService {
* @return Le temps entre les deux dates.
*/
private Duration computeDuration(String sessionId, Long formId, ZonedDateTime since) {
Duration duration = Duration.ZERO;
List<UserAction> userActions = userActionRepository.findAllBySessionIdAndScreenFormIdOrderByDateTimeDesc(sessionId, formId);
Optional<UserAction> lastUserAction = userActions.stream().findFirst();
lastUserAction.ifPresent(userAction -> Duration.between(userAction.getDateTime(), since));
return duration;
return lastUserAction.map(userAction -> Duration.between(userAction.getDateTime(), since)).orElse(Duration.ZERO);
}
}
......@@ -84,9 +84,9 @@ class FormApiDelegateImplTest extends AbstractTest {
private ServiceConverter serviceConverter;
private Answer answerS02;
@Autowired
private UserActionIntegrationService userActionIntegrationService;
@BeforeEach
......@@ -128,6 +128,7 @@ class FormApiDelegateImplTest extends AbstractTest {
when(formRepository.findByReference(DEFAULT_FORM_REFERENCE)).thenReturn(Optional.of(form));
screenRepository = mock(ScreenRepository.class);
answerRepository = mock(AnswerRepository.class);
userActionIntegrationService = mock(UserActionIntegrationService.class);
formApiDelegate = new FormApiDelegateImpl(request, formRepository, screenService, screenRepository, serviceConverter, screenNavigationService, answerRepository, userActionIntegrationService);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment