Fix #6652 Backend: Sort Feed by created timestamp by default (#6653)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-08-13 11:41:38 -07:00 committed by GitHub
parent 11eddedf03
commit d04a28e45b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -542,7 +542,7 @@ public interface CollectionDAO {
@SqlQuery("SELECT json FROM thread_entity WHERE id = :id")
String findById(@Bind("id") String id);
@SqlQuery("SELECT json FROM thread_entity ORDER BY updatedAt DESC")
@SqlQuery("SELECT json FROM thread_entity ORDER BY createdAt DESC")
List<String> list();
@SqlQuery(
@ -592,7 +592,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity "
+ "WHERE updatedAt > :before AND resolved = :resolved "
+ "AND (:type IS NULL OR type = :type) AND (:status IS NULL OR taskStatus = :status) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listBefore(
@Bind("limit") int limit,
@ -640,7 +640,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity "
+ "WHERE updatedAt > :before "
+ "AND type = :type AND <mysqlCond> "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = MYSQL)
@ConnectionAwareSqlQuery(
@ -648,7 +648,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity "
+ "WHERE updatedAt > :before "
+ "AND type = :type AND <postgresCond> "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = POSTGRES)
List<String> listAnnouncementBefore(
@ -680,7 +680,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity "
+ "WHERE updatedAt < :after "
+ "AND type = :type AND <mysqlCond> "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = MYSQL)
@ConnectionAwareSqlQuery(
@ -688,7 +688,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity "
+ "WHERE updatedAt < :after "
+ "AND type = :type AND <postgresCond> "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = POSTGRES)
List<String> listAnnouncementAfter(
@ -702,7 +702,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity "
+ "WHERE updatedAt < :after AND resolved = :resolved "
+ "AND (:type IS NULL OR type = :type) AND (:status IS NULL OR taskStatus = :status) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listAfter(
@Bind("limit") int limit,
@ -715,14 +715,14 @@ public interface CollectionDAO {
value =
"SELECT json FROM thread_entity WHERE type='Task' AND updatedAt > :before AND taskStatus = :status AND "
+ "taskAssignees @> ANY (ARRAY[<userTeamJsonPostgres>]::jsonb[]) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = POSTGRES)
@ConnectionAwareSqlQuery(
value =
"SELECT json FROM thread_entity WHERE type='Task' AND updatedAt > :before AND taskStatus = :status AND "
+ "JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = MYSQL)
List<String> listTasksAssignedToBefore(
@ -737,7 +737,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity WHERE type='Task' AND updatedAt < :after "
+ "AND (:status IS NULL OR taskStatus = :status) "
+ "AND taskAssignees @> ANY (ARRAY[<userTeamJsonPostgres>]::jsonb[]) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = POSTGRES)
@ConnectionAwareSqlQuery(
@ -745,7 +745,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity WHERE type='Task' AND updatedAt < :after "
+ "AND (:status IS NULL OR taskStatus = :status) "
+ "AND JSON_OVERLAPS(taskAssignees, :userTeamJsonMysql) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = MYSQL)
List<String> listTasksAssignedToAfter(
@ -776,7 +776,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity WHERE type='Task' AND updatedAt > :before "
+ "AND (:status IS NULL OR taskStatus = :status) "
+ "AND createdBy = :username "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listTasksAssignedByBefore(
@Bind("username") String username,
@ -788,7 +788,7 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity WHERE type='Task' AND updatedAt < :after "
+ "AND (:status IS NULL OR taskStatus = :status) "
+ "AND createdBy = :username "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listTasksAssignedByAfter(
@Bind("username") String username,
@ -807,7 +807,7 @@ public interface CollectionDAO {
+ "((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)))) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByOwnerBefore(
@Bind("userId") String userId,
@ -823,7 +823,7 @@ public interface CollectionDAO {
+ "((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)))) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByOwnerAfter(
@Bind("userId") String userId,
@ -878,7 +878,7 @@ public interface CollectionDAO {
+ "AND id in (SELECT fromFQN FROM field_relationship WHERE "
+ "(:fqnPrefix IS NULL OR toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(:toType IS NULL OR toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = MYSQL)
@ConnectionAwareSqlQuery(
@ -888,7 +888,7 @@ public interface CollectionDAO {
+ "AND id in (SELECT fromFQN FROM field_relationship WHERE "
+ "(:fqnPrefix IS NULL OR toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(:toType IS NULL OR toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = POSTGRES)
List<String> listAnnouncementsByEntityLinkBefore(
@ -908,7 +908,7 @@ public interface CollectionDAO {
+ "AND id in (SELECT fromFQN FROM field_relationship WHERE "
+ "(:fqnPrefix IS NULL OR toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(:toType IS NULL OR toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByEntityLinkBefore(
@Bind("fqnPrefix") String fqnPrefix,
@ -953,7 +953,7 @@ public interface CollectionDAO {
+ "AND id in (SELECT fromFQN FROM field_relationship WHERE "
+ "(:fqnPrefix IS NULL OR toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(:toType IS NULL OR toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = MYSQL)
@ConnectionAwareSqlQuery(
@ -963,7 +963,7 @@ public interface CollectionDAO {
+ "AND id in (SELECT fromFQN FROM field_relationship WHERE "
+ "(:fqnPrefix IS NULL OR toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(:toType IS NULL OR toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit",
connectionType = POSTGRES)
List<String> listAnnouncementsByEntityLinkAfter(
@ -983,7 +983,7 @@ public interface CollectionDAO {
+ "AND id in (SELECT fromFQN FROM field_relationship WHERE "
+ "(:fqnPrefix IS NULL OR toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(:toType IS NULL OR toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByEntityLinkAfter(
@Bind("fqnPrefix") String fqnPrefix,
@ -1111,7 +1111,7 @@ public interface CollectionDAO {
+ "SELECT toId FROM entity_relationship WHERE "
+ "((fromEntity='user' AND fromId= :userId) OR "
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByFollowsBefore(
@Bind("userId") String userId,
@ -1128,7 +1128,7 @@ public interface CollectionDAO {
+ "SELECT toId FROM entity_relationship WHERE "
+ "((fromEntity='user' AND fromId= :userId) OR "
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByFollowsAfter(
@Bind("userId") String userId,
@ -1158,7 +1158,7 @@ public interface CollectionDAO {
+ "SELECT toFQN FROM field_relationship WHERE "
+ "((fromType='user' AND fromFQN= :userName) OR "
+ "(fromType='team' AND fromFQN IN (<teamNames>))) AND toType='THREAD' AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByMentionsBefore(
@Bind("userName") String userName,
@ -1175,7 +1175,7 @@ public interface CollectionDAO {
+ "SELECT toFQN FROM field_relationship WHERE "
+ "((fromType='user' AND fromFQN= :userName) OR "
+ "(fromType='team' AND fromFQN IN (<teamNames>))) AND toType='THREAD' AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "ORDER BY createdAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByMentionsAfter(
@Bind("userName") String userName,