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: cache contacts size (WPB-14523) #3259

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

Conversation

ohassine
Copy link
Member

@ohassine ohassine commented Jan 29, 2025

TaskWPB-14523 [Android] Modification of the app.open event


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?

Description

Caching contacts size to use it for Countly events.

Needs releases with:

  • GitHub link to other pull request

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Briefly describe how this change was tested and if applicable the exact steps taken to verify that it works as expected.

Notes (Optional)

Specify here any other facts that you think are important for this issue.

Attachments (Optional)

Attachments like images, videos, etc. (drag and drop in the text box)


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

Comment on lines 712 to 714
override suspend fun getContactsSize(): Either<StorageFailure, Int> = wrapStorageRequest {
userDAO.countUsers()
}
Copy link
Member

Choose a reason for hiding this comment

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

Just to be sure... I am not sure what a "contact" is. userDAO.countUsers() is returning a count of known users. These users not necessarily have connection requests, etc.

Edit: I scrolled down and saw the query is explicitly querying accepted connections, not only "known users".

Maybe getEstablishedConnectionsCount instead of getContactsSize ?

Comment on lines 284 to 286
countUsers:
SELECT COUNT(*)
FROM User WHERE connection_status == 'ACCEPTED';
Copy link
Member

Choose a reason for hiding this comment

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

The name says countUsers, but it only counts accepted connections.

Maybe getEstablishedConnectionsCount.

Also, from a product point of view, should it also count known team mates, for example?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should count the number of user contacts.

Copy link
Contributor

github-actions bot commented Jan 29, 2025

Test Results

3 410 tests  ±0   3 302 ✅ ±0   5m 45s ⏱️ -21s
  584 suites ±0     108 💤 ±0 
  584 files   ±0       0 ❌ ±0 

Results for commit 1d513b0. ± Comparison against base commit f4afb2a.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Jan 29, 2025

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Project coverage is 53.88%. Comparing base (f4afb2a) to head (1d513b0).

Files with missing lines Patch % Lines
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 0.00% 6 Missing ⚠️
.../com/wire/kalium/logic/data/user/UserRepository.kt 0.00% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3259      +/-   ##
===========================================
- Coverage    53.90%   53.88%   -0.03%     
===========================================
  Files         1303     1303              
  Lines        37396    37404       +8     
  Branches      3770     3771       +1     
===========================================
- Hits         20159    20155       -4     
- Misses       15828    15839      +11     
- Partials      1409     1410       +1     
Files with missing lines Coverage Δ
.../kotlin/com/wire/kalium/persistence/dao/UserDAO.kt 95.41% <ø> (ø)
.../com/wire/kalium/logic/data/user/UserRepository.kt 62.21% <0.00%> (-0.62%) ⬇️
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 50.79% <0.00%> (-0.50%) ⬇️

... 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 f4afb2a...1d513b0. Read the comment docs.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Jan 29, 2025

Datadog Report

Branch report: count-contacts
Commit report: 18d5ad6
Test service: kalium-jvm

✅ 0 Failed, 3302 Passed, 108 Skipped, 1m 2.91s Total Time

Comment on lines 283 to 285

countUsers:
SELECT COUNT(*)
Copy link
Member

Choose a reason for hiding this comment

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

connection_status have no index and it can make this query very slow

Copy link
Member Author

Choose a reason for hiding this comment

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

Added index on the connection_status column

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants