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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

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 323 tests  +18   3 216 ✅ +18   5m 13s ⏱️ +3s
  568 suites + 4     107 💤 ± 0 
  568 files   + 4       0 ❌ ± 0 

Results for commit 761f2bc. ± Comparison against base commit 08c0cff.

♻️ 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 83.52941% with 14 lines in your changes missing coverage. Please review.

Project coverage is 54.13%. Comparing base (08c0cff) to head (761f2bc).

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.03%   54.13%   +0.09%     
===========================================
  Files         1246     1247       +1     
  Lines        36152    36234      +82     
  Branches      3656     3657       +1     
===========================================
+ Hits         19534    19614      +80     
+ Misses       15208    15207       -1     
- Partials      1410     1413       +3     
Files with missing lines Coverage Δ
.../conversation/folders/ConversationFolderMappers.kt 65.21% <100.00%> (+5.21%) ⬆️
...nversation/folders/ConversationFolderRepository.kt 93.93% <100.00%> (+2.63%) ⬆️
...sation/folder/AddConversationToFavoritesUseCase.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%) ⬆️
...um/logic/feature/conversation/ConversationScope.kt 0.00% <0.00%> (ø)
... and 3 more

... and 5 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 08c0cff...761f2bc. 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: a655f4d
Test service: kalium-jvm

✅ 0 Failed, 3216 Passed, 107 Skipped, 40.56s Total Time

Copy link

sonarcloud bot commented Nov 21, 2024

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.

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