Skip to content

Commit

Permalink
feat: missing accent id for messages detail, reactions and receipts (…
Browse files Browse the repository at this point in the history
…WPB-1750) (#2980)

* feat: missing accent id for messages detail, reactions and receipts

* feat: tests

* feat: tests
  • Loading branch information
yamilmedina authored Aug 30, 2024
1 parent eeadc6d commit 10ce34e
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ data class UserSummary(
val userType: UserType,
val isUserDeleted: Boolean,
val connectionStatus: ConnectionState,
val availabilityStatus: UserAvailabilityStatus
val availabilityStatus: UserAvailabilityStatus,
val accentId: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ internal class ReactionsMapperImpl(
userTypeEntity = userType,
deleted = deleted,
connectionStatus = connectionStatus,
availabilityStatus = userAvailabilityStatus
availabilityStatus = userAvailabilityStatus,
accentId = accentId
)
}

Expand All @@ -71,7 +72,8 @@ internal class ReactionsMapperImpl(
userType = domainUserTypeMapper.fromUserTypeEntity(userTypeEntity),
isUserDeleted = deleted,
connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus),
availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus)
availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus),
accentId = accentId
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ internal class ReceiptsMapperImpl(
userType = domainUserTypeMapper.fromUserTypeEntity(userType),
isUserDeleted = isUserDeleted,
connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus),
availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus)
availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus),
accentId = accentId
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ internal class UserMapperImpl(
userType = domainUserTypeMapper.fromUserTypeEntity(userType),
isUserDeleted = deleted,
availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus),
connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus)
connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus),
accentId = accentId
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class ReactionsMapperTest {
userType = UserTypeEntity.STANDARD,
deleted = false,
connectionStatus = ConnectionEntity.State.ACCEPTED,
userAvailabilityStatus = UserAvailabilityStatusEntity.NONE
userAvailabilityStatus = UserAvailabilityStatusEntity.NONE,
accentId = 0
)

val expectedMessageReactionEntity = MessageReactionEntity(
Expand All @@ -71,7 +72,8 @@ class ReactionsMapperTest {
userTypeEntity = UserTypeEntity.STANDARD,
deleted = false,
connectionStatus = ConnectionEntity.State.ACCEPTED,
availabilityStatus = UserAvailabilityStatusEntity.NONE
availabilityStatus = UserAvailabilityStatusEntity.NONE,
accentId = 0
)

val (_, reactionsMapper) = Arrangement()
Expand Down Expand Up @@ -99,7 +101,8 @@ class ReactionsMapperTest {
userTypeEntity = UserTypeEntity.STANDARD,
deleted = false,
connectionStatus = ConnectionEntity.State.ACCEPTED,
availabilityStatus = UserAvailabilityStatusEntity.NONE
availabilityStatus = UserAvailabilityStatusEntity.NONE,
accentId = 0
)

val expectedMessageReaction = MessageReaction(
Expand All @@ -113,7 +116,8 @@ class ReactionsMapperTest {
userType = UserType.INTERNAL,
isUserDeleted = false,
connectionStatus = ConnectionState.ACCEPTED,
availabilityStatus = UserAvailabilityStatus.NONE
availabilityStatus = UserAvailabilityStatus.NONE,
accentId = 0
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class ReceiptsMapperTest {
isUserDeleted = false,
connectionStatus = ConnectionEntity.State.ACCEPTED,
availabilityStatus = UserAvailabilityStatusEntity.NONE,
date = date
date = date,
accentId = 0
)

val expectedDetailedReceipt = DetailedReceipt(
Expand All @@ -132,7 +133,8 @@ class ReceiptsMapperTest {
userType = UserType.INTERNAL,
isUserDeleted = false,
connectionStatus = ConnectionState.ACCEPTED,
availabilityStatus = UserAvailabilityStatus.NONE
availabilityStatus = UserAvailabilityStatus.NONE,
accentId = 0
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class ObserveMessageReactionsUseCaseTest {
userType = UserType.INTERNAL,
isUserDeleted = false,
connectionStatus = ConnectionState.ACCEPTED,
availabilityStatus = UserAvailabilityStatus.NONE
availabilityStatus = UserAvailabilityStatus.NONE,
accentId = 0
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class ObserveMessageReceiptsUseCaseTest {
userType = UserType.INTERNAL,
isUserDeleted = false,
connectionStatus = ConnectionState.ACCEPTED,
availabilityStatus = UserAvailabilityStatus.NONE
availabilityStatus = UserAvailabilityStatus.NONE,
accentId = 0
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ AS SELECT
User.user_type AS userType,
User.deleted,
User.connection_status AS connectionStatus,
User.user_availability_status AS userAvailabilityStatus
User.user_availability_status AS userAvailabilityStatus,
User.accent_id AS accentId
FROM
Reaction
INNER JOIN User ON User.qualified_id = Reaction.sender_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ AS SELECT
User.user_type AS userType,
User.deleted AS isUserDeleted,
User.connection_status AS connectionStatus,
User.user_availability_status AS userAvailabilityStatus
User.user_availability_status AS userAvailabilityStatus,
User.accent_id AS accentId
FROM
Receipt
INNER JOIN User ON User.qualified_id = Receipt.user_id
Expand Down
41 changes: 41 additions & 0 deletions persistence/src/commonMain/db_user/migrations/85.sqm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
DROP VIEW IF EXISTS ReceiptDetails;
DROP VIEW IF EXISTS MessageDetailsReactions;

CREATE VIEW IF NOT EXISTS ReceiptDetails
AS SELECT
Receipt.type,
Receipt.date,
Receipt.message_id AS messageId,
Receipt.conversation_id AS conversationId,
User.qualified_id AS userId,
User.name AS userName,
User.handle AS userHandle,
User.preview_asset_id AS previewAssetId,
User.user_type AS userType,
User.deleted AS isUserDeleted,
User.connection_status AS connectionStatus,
User.user_availability_status AS userAvailabilityStatus,
User.accent_id AS accentId
FROM
Receipt
INNER JOIN User ON User.qualified_id = Receipt.user_id
ORDER BY User.name;

CREATE VIEW IF NOT EXISTS MessageDetailsReactions
AS SELECT
Reaction.emoji,
Reaction.message_id AS messageId,
Reaction.conversation_id AS conversationId,
User.qualified_id AS userId,
User.name,
User.handle,
User.preview_asset_id AS previewAssetId,
User.user_type AS userType,
User.deleted,
User.connection_status AS connectionStatus,
User.user_availability_status AS userAvailabilityStatus,
User.accent_id AS accentId
FROM
Reaction
INNER JOIN User ON User.qualified_id = Reaction.sender_id
ORDER BY Reaction.emoji;
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ object ReactionMapper {
userTypeEntity = userType,
deleted = deleted,
connectionStatus = connectionStatus,
availabilityStatus = userAvailabilityStatus
availabilityStatus = userAvailabilityStatus,
accentId = accentId
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ data class MessageReactionEntity(
val userTypeEntity: UserTypeEntity,
val deleted: Boolean,
val connectionStatus: ConnectionEntity.State,
val availabilityStatus: UserAvailabilityStatusEntity
val availabilityStatus: UserAvailabilityStatusEntity,
val accentId: Int
)

typealias ReactionsCountEntity = Map<String, Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ data class DetailedReceiptEntity(
val userType: UserTypeEntity,
val isUserDeleted: Boolean,
val connectionStatus: ConnectionEntity.State,
val availabilityStatus: UserAvailabilityStatusEntity
val availabilityStatus: UserAvailabilityStatusEntity,
val accentId: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal object ReceiptMapper {
isUserDeleted: Boolean,
connectionStatus: ConnectionEntity.State,
userAvailabilityStatus: UserAvailabilityStatusEntity,
accentId: Int
) = DetailedReceiptEntity(
type = type,
date = Instant.parse(date),
Expand All @@ -51,5 +52,6 @@ internal object ReceiptMapper {
isUserDeleted = isUserDeleted,
connectionStatus = connectionStatus,
availabilityStatus = userAvailabilityStatus,
accentId = accentId
)
}

0 comments on commit 10ce34e

Please sign in to comment.