Skip to content

Commit

Permalink
fix: user role and topic id resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippFr committed Sep 7, 2022
1 parent 3b70c74 commit 2d83023
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.caritas.cob.userservice.api.helper;

import de.caritas.cob.userservice.api.service.consultingtype.TopicService;
import de.caritas.cob.userservice.topicservice.generated.web.model.TopicDTO;
import java.util.Collection;
import java.util.List;
Expand All @@ -15,7 +16,8 @@
@Slf4j
@Component
public class RegistrationStatisticsHelper {
private @NonNull Map<Long, TopicDTO> allTopicsMap;

private final @NonNull TopicService topicService;

public List<String> findTopicsInternalAttributes(Collection<Integer> topicsList) {
return topicsList.stream().map(this::findTopicInternalIdentifier).collect(Collectors.toList());
Expand All @@ -26,6 +28,7 @@ public String findTopicInternalIdentifier(Integer topicId) {
}

private Optional<String> findTopicInternalIdentifierInTopicsMap(Integer topicId) {
Map<Long, TopicDTO> allTopicsMap = topicService.getAllTopicsMap();
Long key = Long.valueOf(topicId);
if (allTopicsMap.containsKey(key)) {
return Optional.ofNullable(allTopicsMap.get(key).getInternalIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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.Optional;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -59,6 +60,7 @@ public Optional<String> getPayload() {
.eventType(EVENT_TYPE)
.sessionId(sessionId)
.userId(createdUser.getUserId())
.userRole(UserRole.ASKER)
.registrationDate(toIsoTime(createdUser.getCreateDate()))
.age(registeredUser.getUserAge())
.gender(registeredUser.getUserGender())
Expand Down

0 comments on commit 2d83023

Please sign in to comment.