taskCount should show total count for openedBy or assignedTo a user (#15016)

This commit is contained in:
Sriharsha Chintalapani 2024-02-04 03:54:12 -08:00 committed by GitHub
parent f817921750
commit 87efc57394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 11 deletions

View File

@ -1189,18 +1189,37 @@ public interface CollectionDAO {
@BindFQN("fqnPrefixHash") String fqnPrefixHash,
@Bind("toType") String toType);
@SqlQuery(
"SELECT te.type, te.taskStatus, COUNT(id) count FROM thread_entity te where "
+ "(entityId in (SELECT toId FROM entity_relationship WHERE "
+ "((fromEntity='user' AND fromId= :userId) OR "
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation=8) OR "
+ "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 (<teamIds>))) AND relation=11)) "
+ "GROUP BY te.type, te.taskStatus")
@ConnectionAwareSqlQuery(
value =
"SELECT te.type, te.taskStatus, COUNT(id) count FROM thread_entity te where "
+ "(entityId in (SELECT toId FROM entity_relationship WHERE "
+ "((fromEntity='user' AND fromId= :userId) OR "
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation=8) OR "
+ "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 (<teamIds>))) AND relation=11)) "
+ " OR (taskAssignees @> ANY (ARRAY[<userTeamJsonPostgres>]::jsonb[]) OR createdBy = :username)"
+ "GROUP BY te.type, te.taskStatus",
connectionType = POSTGRES)
@ConnectionAwareSqlQuery(
value =
"SELECT te.type, te.taskStatus, COUNT(id) count FROM thread_entity te where "
+ "(entityId in (SELECT toId FROM entity_relationship WHERE "
+ "((fromEntity='user' AND fromId= :userId) OR "
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation=8) OR "
+ "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 (<teamIds>))) AND relation=11)) OR "
+ "(JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) OR createdBy = :username)"
+ "GROUP BY te.type, te.taskStatus",
connectionType = MYSQL)
@RegisterRowMapper(OwnerCountFieldMapper.class)
List<List<String>> listCountByOwner(
@BindUUID("userId") UUID userId, @BindList("teamIds") List<String> teamIds);
@BindUUID("userId") UUID userId,
@BindList("teamIds") List<String> teamIds,
@Bind("username") String username,
@Bind("userTeamJsonMysql") String userTeamJsonMysql,
@BindList("userTeamJsonPostgres") List<String> userTeamJsonPostgres);
@SqlQuery(
"SELECT json FROM thread_entity <condition> AND "

View File

@ -528,7 +528,12 @@ public class FeedRepository {
User user = Entity.getEntity(USER, userId, TEAMS_FIELD, NON_DELETED);
List<String> teamIds = getTeamIds(user);
List<String> teamNames = getTeamNames(user);
result = dao.feedDAO().listCountByOwner(userId, teamIds);
String userTeamJsonMysql = getUserTeamJsonMysql(userId, teamIds);
List<String> userTeamJsonPostgres = getUserTeamJsonPostgres(userId, teamIds);
result =
dao.feedDAO()
.listCountByOwner(
userId, teamIds, user.getName(), userTeamJsonMysql, userTeamJsonPostgres);
mentions =
dao.feedDAO()
.listCountThreadsByMentions(