Skip to content

Commit

Permalink
fix: move bean to request context because of async issue
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippFr committed Sep 8, 2022
1 parent 2d83023 commit 6eae84a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public void createUserAccountWithInitializedConsultingType(final UserDTO userDTO

RegistrationStatisticsEvent registrationEvent =
new RegistrationStatisticsEvent(
userDTO, user, newRegistrationResponseDto.getSessionId(), registrationStatisticsHelper);
userDTO,
user,
newRegistrationResponseDto.getSessionId(),
registrationStatisticsHelper.findTopicInternalIdentifier(userDTO.getMainTopicId()),
registrationStatisticsHelper.findTopicsInternalAttributes(userDTO.getTopicIds()));
statisticsService.fireEvent(registrationEvent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import de.caritas.cob.userservice.api.adapters.web.dto.UserDTO;
import de.caritas.cob.userservice.api.helper.CustomOffsetDateTime;
import de.caritas.cob.userservice.api.helper.RegistrationStatisticsHelper;
import de.caritas.cob.userservice.api.helper.json.OffsetDateTimeToStringSerializer;
import de.caritas.cob.userservice.api.model.User;
import de.caritas.cob.userservice.statisticsservice.generated.web.model.EventType;
import de.caritas.cob.userservice.statisticsservice.generated.web.model.RegistrationStatisticsEventMessage;
import de.caritas.cob.userservice.statisticsservice.generated.web.model.UserRole;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -27,17 +27,20 @@ public class RegistrationStatisticsEvent implements StatisticsEvent {
private final UserDTO registeredUser;
private final User createdUser;
private final Long sessionId;
private final RegistrationStatisticsHelper registrationStatisticsHelper;
private final String mainTopicInternalAttribute;
private final List<String> topicsInternalAttributes;

public RegistrationStatisticsEvent(
UserDTO registeredUser,
User createdUser,
Long sessionId,
RegistrationStatisticsHelper registrationStatisticsHelper) {
String mainTopicInternalAttribute,
List<String> topicsInternalAttributes) {
this.registeredUser = registeredUser;
this.createdUser = createdUser;
this.sessionId = sessionId;
this.registrationStatisticsHelper = registrationStatisticsHelper;
this.mainTopicInternalAttribute = mainTopicInternalAttribute;
this.topicsInternalAttributes = topicsInternalAttributes;
OBJECT_MAPPER.registerModule(new JavaTimeModule());
OBJECT_MAPPER.registerModule(buildSimpleModule());
}
Expand Down Expand Up @@ -65,12 +68,8 @@ public Optional<String> getPayload() {
.age(registeredUser.getUserAge())
.gender(registeredUser.getUserGender())
.counsellingRelation(registeredUser.getCounsellingRelation())
.mainTopicInternalAttribute(
registrationStatisticsHelper.findTopicInternalIdentifier(
registeredUser.getMainTopicId()))
.topicsInternalAttributes(
registrationStatisticsHelper.findTopicsInternalAttributes(
registeredUser.getTopicIds()))
.mainTopicInternalAttribute(mainTopicInternalAttribute)
.topicsInternalAttributes(topicsInternalAttributes)
.postalCode(registeredUser.getPostcode())
.timestamp(CustomOffsetDateTime.nowInUtc());

Expand Down

0 comments on commit 6eae84a

Please sign in to comment.