Skip to content

Commit

Permalink
Use find first instead of find all
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Nuyanzin <snuyanzin@gmail.com>
  • Loading branch information
snuyanzin committed Aug 18, 2023
1 parent b441218 commit 3a1b31d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1381,17 +1381,11 @@ public String getRegistrationId(String userId) {
}

public RegisterUserInfo getRegistrationDetails(String registrationId, String status) {
List<RegisterUserInfo> registerUserInfoList;
if ("".equals(status)) {
registerUserInfoList = registerInfoRepo.findAllByRegistrationId(registrationId);
return registerInfoRepo.findFirstByRegistrationId(registrationId);
} else {
registerUserInfoList =
registerInfoRepo.findAllByRegistrationIdAndStatus(registrationId, status);
return registerInfoRepo.findFirstByRegistrationIdAndStatus(registrationId, status);
}
if (registerUserInfoList.size() == 1) {
return registerUserInfoList.get(0);
}
return null;
}

public List<Topic> getTopicsforTeam(Integer teamId, int tenantId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public interface RegisterInfoRepo extends CrudRepository<RegisterUserInfo, Strin

List<RegisterUserInfo> findAllByTenantId(int tenantId);

List<RegisterUserInfo> findAllByRegistrationIdAndStatus(String registrationId, String status);

RegisterUserInfo findFirstByUsernameAndStatus(String userId, String status);

boolean existsRegisterUserInfoByUsernameAndStatus(String userId, String status);

List<RegisterUserInfo> findAllByRegistrationId(String registrationId);
RegisterUserInfo findFirstByRegistrationId(String registrationId);

RegisterUserInfo findFirstByRegistrationIdAndStatus(String registrationId, String status);

void deleteByTenantId(int tenantId);
}
4 changes: 2 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7096,10 +7096,10 @@
"type" : "integer",
"format" : "int32"
},
"topicOwner" : {
"highestEnv" : {
"type" : "boolean"
},
"highestEnv" : {
"topicOwner" : {
"type" : "boolean"
}
},
Expand Down

0 comments on commit 3a1b31d

Please sign in to comment.