Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add and remove conversation favorite [WPB-11639] #3119

Merged
merged 7 commits into from
Nov 25, 2024

Conversation

Garzas
Copy link
Contributor

@Garzas Garzas commented Nov 21, 2024

StoryWPB-11639 [Android] User Story for Add to favourites/Remove from favourites


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

  • use cases for adding and removing conversation to favorites
  • syncConversationFoldersFromLocal for updating all folders from local to API
  • updated slow sync manager version to sync all folders from API
  • added isFavorite to conversation details view

@Garzas Garzas self-assigned this Nov 21, 2024
@echoes-hq echoes-hq bot added the echoes: product-roadmap Work aligned with the customer-announced roadmap, targeting a specific release date. label Nov 21, 2024
@Garzas Garzas changed the title Feat/manage favorite folder [WPB-11639] feat: add and remove conversation favorite [WPB-11639] Nov 21, 2024
Copy link
Contributor

github-actions bot commented Nov 21, 2024

Test Results

3 327 tests  +18   3 220 ✅ +18   5m 1s ⏱️ +18s
  569 suites + 4     107 💤 ± 0 
  569 files   + 4       0 ❌ ± 0 

Results for commit 8630eb2. ± Comparison against base commit e271934.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Nov 21, 2024

@codecov-commenter
Copy link

codecov-commenter commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 85.85859% with 14 lines in your changes missing coverage. Please review.

Project coverage is 54.14%. Comparing base (e271934) to head (8630eb2).

Files with missing lines Patch % Lines
...o/conversation/folder/ConversationFolderDAOImpl.kt 79.16% 3 Missing and 2 partials ⚠️
...ire/kalium/logic/data/conversation/Conversation.kt 0.00% 3 Missing ⚠️
...um/network/api/v0/authenticated/PropertiesApiV0.kt 0.00% 3 Missing ⚠️
...um/logic/feature/conversation/ConversationScope.kt 0.00% 2 Missing ⚠️
...lium/logic/data/conversation/ConversationMapper.kt 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3119      +/-   ##
===========================================
+ Coverage    54.02%   54.14%   +0.11%     
===========================================
  Files         1247     1249       +2     
  Lines        36176    36272      +96     
  Branches      3658     3658              
===========================================
+ Hits         19545    19639      +94     
  Misses       15220    15220              
- Partials      1411     1413       +2     
Files with missing lines Coverage Δ
.../conversation/folders/ConversationFolderMappers.kt 65.21% <100.00%> (+5.21%) ⬆️
...nversation/folders/ConversationFolderRepository.kt 93.65% <100.00%> (+2.34%) ⬆️
...sation/folder/AddConversationToFavoritesUseCase.kt 100.00% <100.00%> (ø)
...n/folder/RemoveConversationFromFavoritesUseCase.kt 100.00% <100.00%> (ø)
...com/wire/kalium/logic/sync/slow/SlowSyncManager.kt 93.02% <ø> (ø)
...onversation/ConversationDetailsWithEventsMapper.kt 92.63% <100.00%> (+0.07%) ⬆️
...persistence/dao/conversation/ConversationMapper.kt 97.89% <100.00%> (+0.02%) ⬆️
...istence/dao/conversation/ConversationViewEntity.kt 97.91% <100.00%> (+0.04%) ⬆️
...ao/conversation/folder/ConversationFolderEntity.kt 100.00% <100.00%> (ø)
...lium/logic/data/conversation/ConversationMapper.kt 58.02% <66.66%> (+0.18%) ⬆️
... and 4 more

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e271934...8630eb2. Read the comment docs.

---- 🚨 Try these New Features:

@datadog-wireapp
Copy link

datadog-wireapp bot commented Nov 21, 2024

Datadog Report

Branch report: feat/manage-favorite-folder
Commit report: 0013516
Test service: kalium-jvm

✅ 0 Failed, 3220 Passed, 107 Skipped, 36.5s Total Time

Comment on lines 111 to 119
END AS interactionEnabled,
CASE WHEN EXISTS (
SELECT 1
FROM LabeledConversation lc
JOIN ConversationFolder cf ON lc.folder_id = cf.id
WHERE lc.conversation_id = Conversation.qualified_id
AND cf.folder_type = 'FAVORITE'
)
THEN 1 ELSE 0 END AS isFavorite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: making multiple nested queries can be expensive.
I would suggest to change it to use joins, like:

LabeledConversation.folder_id IS NOT NULL AS isFavorite
FROM Conversation
LEFT JOIN ConversationFolder AS FavoriteFolder ON FavoriteFolder.folder_type = 'FAVORITE'
LEFT JOIN LabeledConversation ON LabeledConversation.conversation_id = Conversation.id AND LabeledConversation.folder_id = FavoriteFolder.id

First left join filters out and joins only favorite folder, second left join adds given conversation's folders but filters them so that it only adds the one which matches with favorite folder id, so in the end LabeledConversation.folder_id is equal to favorite folder id or NULL if this conversation is not in favorite folder 😄

@@ -17,6 +17,19 @@ CREATE TABLE LabeledConversation (
PRIMARY KEY (folder_id, conversation_id)
);

getFolderWithConversations:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is it supposed to return all folders? Then maybe name it getAllFoldersWithConversations? 🤔

@@ -0,0 +1,125 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change: name of the file is RemoveConversationFromFaroritesUseCase without Test at the end 😄

Comment on lines 131 to 137
return wrapStorageRequest {
conversationFolderDAO.addConversationToFolder(conversationId.toDao(), folderId)
}
.flatMap {
syncConversationFoldersFromLocal()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to move syncConversationFoldersFromLocal() to the usecase.

Repository should stay as dummy class, it just interacts with data sources by providing CRUD operations and do data transformation.

Comment on lines 144 to 146
}.flatMap {
syncConversationFoldersFromLocal()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines +149 to +159
override suspend fun syncConversationFoldersFromLocal(): Either<CoreFailure, Unit> {
kaliumLogger.withFeatureId(CONVERSATIONS_FOLDERS).v("Syncing conversation folders from local")
return wrapStorageRequest { conversationFolderDAO.getFoldersWithConversations().map { it.toModel() } }
.flatMap {
wrapApiRequest {
userPropertiesApi.updateLabels(
LabelListResponseDTO(it.map { it.toLabel() })
)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also breaking the separation of concerns.

We can have this logic in a use case, as it's responsible for orchestrating business logic.

Copy link

sonarcloud bot commented Nov 25, 2024

@Garzas Garzas added this pull request to the merge queue Nov 25, 2024
Merged via the queue into develop with commit c7b96a2 Nov 25, 2024
22 checks passed
@Garzas Garzas deleted the feat/manage-favorite-folder branch November 25, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: product-roadmap Work aligned with the customer-announced roadmap, targeting a specific release date. 🚨 Potential breaking changes 👕 size: XXL type: feature ✨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants