mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 19:18:05 +00:00
GEN-1937 : Fix - User count doesn’t update on adding to the team while using search (#18516)
This commit is contained in:
parent
3dcbeb469f
commit
1ade1d4eb6
@ -971,6 +971,13 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void postUpdate(T updated) {
|
||||
if (supportsSearch) {
|
||||
searchRepository.updateEntity(updated);
|
||||
}
|
||||
}
|
||||
|
||||
@Transaction
|
||||
public final PutResponse<T> update(UriInfo uriInfo, T original, T updated) {
|
||||
// Get all the fields in the original entity that can be updated during PUT operation
|
||||
|
||||
@ -798,6 +798,8 @@ public class TeamRepository extends EntityRepository<Team> {
|
||||
origUsers,
|
||||
updatedUsers,
|
||||
false);
|
||||
|
||||
updatedTeam.setUserCount(updatedUsers.size());
|
||||
}
|
||||
|
||||
private void updateDefaultRoles(Team origTeam, Team updatedTeam) {
|
||||
|
||||
@ -36,6 +36,7 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -43,6 +44,7 @@ import org.apache.commons.csv.CSVPrinter;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.csv.EntityCsv;
|
||||
import org.openmetadata.schema.EntityInterface;
|
||||
import org.openmetadata.schema.api.teams.CreateTeam.TeamType;
|
||||
import org.openmetadata.schema.api.teams.CreateUser;
|
||||
import org.openmetadata.schema.entity.teams.AuthenticationMechanism;
|
||||
@ -709,6 +711,14 @@ public class UserRepository extends EntityRepository<User> {
|
||||
List<EntityReference> deleted = new ArrayList<>();
|
||||
recordListChange(
|
||||
TEAMS_FIELD, origTeams, updatedTeams, added, deleted, EntityUtil.entityReferenceMatch);
|
||||
|
||||
// Update users and userCount in team search index
|
||||
Stream.concat(added.stream(), deleted.stream())
|
||||
.forEach(
|
||||
teamRef -> {
|
||||
EntityInterface team = Entity.getEntity(teamRef, "id,userCount", Include.ALL);
|
||||
searchRepository.updateEntity(team);
|
||||
});
|
||||
}
|
||||
|
||||
private void updatePersonas(User original, User updated) {
|
||||
|
||||
@ -192,6 +192,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"userCount" : {
|
||||
"type" : "long"
|
||||
},
|
||||
"parents": {
|
||||
"properties": {
|
||||
"id": {
|
||||
|
||||
@ -188,6 +188,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"userCount" : {
|
||||
"type" : "long"
|
||||
},
|
||||
"parents": {
|
||||
"properties": {
|
||||
"id": {
|
||||
|
||||
@ -179,6 +179,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"userCount" : {
|
||||
"type" : "long"
|
||||
},
|
||||
"parents": {
|
||||
"properties": {
|
||||
"id": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user