diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java index b99676ccc70..bdd5e042120 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java @@ -977,7 +977,7 @@ public interface CollectionDAO { @ConnectionAwareSqlQuery( value = "SELECT json FROM thread_entity AND " - + "JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) " + + "JSON_OVERLAPS(json_extract(taskAssignees, '$[*].id'), :userTeamJsonMysql) " + "ORDER BY createdAt DESC " + "LIMIT :limit", connectionType = MYSQL) @@ -995,7 +995,7 @@ public interface CollectionDAO { @ConnectionAwareSqlQuery( value = "SELECT count(id) FROM thread_entity AND " - + "JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) ", + + "JSON_OVERLAPS(json_extract(taskAssignees, '$[*].id'), :userTeamJsonMysql) ", connectionType = MYSQL) int listCountTasksAssignedTo( @BindList("userTeamJsonPostgres") List userTeamJsonPostgres, @@ -1012,7 +1012,7 @@ public interface CollectionDAO { @ConnectionAwareSqlQuery( value = "SELECT json FROM thread_entity " - + "AND (JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) OR createdBy = :username) " + + "AND (JSON_OVERLAPS(JSON_EXTRACT(taskAssignees, '$[*].id'), :userTeamJsonMysql) OR createdBy = :username) " + "ORDER BY createdAt DESC " + "LIMIT :limit", connectionType = MYSQL) @@ -1031,7 +1031,7 @@ public interface CollectionDAO { @ConnectionAwareSqlQuery( value = "SELECT count(id) FROM thread_entity " - + "AND (JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) OR createdBy = :username) ", + + "AND (JSON_OVERLAPS(JSON_EXTRACT(taskAssignees, '$[*].id'), :userTeamJsonMysql) OR createdBy = :username) ", connectionType = MYSQL) int listCountTasksOfUser( @BindList("userTeamJsonPostgres") List userTeamJsonPostgres, @@ -1210,8 +1210,8 @@ public interface CollectionDAO { + "id in (SELECT toId FROM entity_relationship WHERE (fromEntity='user' AND fromId= :userId AND toEntity='THREAD' AND relation IN (1,2))) " + " OR id in (SELECT toId FROM entity_relationship WHERE ((fromEntity='user' AND fromId= :userId) OR " + "(fromEntity='team' AND fromId IN ())) AND relation=11)) OR " - + "(JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) OR createdBy = :username)" - + "GROUP BY te.type, te.taskStatus", + + "(JSON_OVERLAPS(JSON_EXTRACT(taskAssignees, '$[*].id'), :userTeamJsonMysql) OR createdBy = :username)" + + " GROUP BY te.type, te.taskStatus", connectionType = MYSQL) @RegisterRowMapper(OwnerCountFieldMapper.class) List> listCountByOwner( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java index 14b2ab0abf3..e9fdc6bd1fb 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java @@ -965,12 +965,9 @@ public class FeedRepository { } private String getUserTeamJsonMysql(UUID userId, List teamIds) { - // Build a string like this for the tasks filter - // [{"id":"9e78b924-b75c-4141-9845-1b3eb81fdc1b","type":"team"},{"id":"fe21e1ba-ce00-49fa-8b62-3c9a6669a11b","type":"user"}] List result = new ArrayList<>(); - JSONObject json = getUserTeamJson(userId, "user"); - result.add(json.toString()); - teamIds.forEach(id -> result.add(getUserTeamJson(id, "team").toString())); + result.add("\"" + userId.toString() + "\""); + teamIds.forEach(id -> result.add("\"" + id + "\"")); return result.toString(); }