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

fix: refactoring self user fetch [#WPB-15190] #3229

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

sbakhtiarov
Copy link
Contributor

@sbakhtiarov sbakhtiarov commented Jan 14, 2025

TaskWPB-15190 [Android] race condition in getKnownUser causes multible requests to update

https://wearezeta.atlassian.net/browse/WPB-15190

What's new in this PR?

Issues

  1. `observeSelfUser' is observing metadata and updating it internally. This caused multiple unnecessary network requests to fetch user.
  2. Self user is requested multiple times on app start and on opening conversation. This causes multiple unnecessary network calls when user validity timeout expires and all requests try to update it simultaneously.

Solutions

  1. Refactor observeSelfUser function to decouple it from userId fetch.
  2. Create separate use cases for getting and observing self user.
  3. Use deferred result for making only one network call to fetch user and suspend parallel requests.

@echoes-hq echoes-hq bot added the echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. label Jan 14, 2025
Copy link
Contributor

github-actions bot commented Jan 14, 2025

Test Results

3 401 tests  ±0   3 293 ✅ ±0   5m 35s ⏱️ -13s
  584 suites ±0     108 💤 ±0 
  584 files   ±0       0 ❌ ±0 

Results for commit f1b3ef1. ± Comparison against base commit b304f30.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Jan 14, 2025

@datadog-wireapp
Copy link

datadog-wireapp bot commented Jan 14, 2025

Datadog Report

Branch report: fix/self-user-refactoring
Commit report: 0afc69b
Test service: kalium-jvm

✅ 0 Failed, 3293 Passed, 108 Skipped, 1m 2.78s Total Time

@sbakhtiarov sbakhtiarov force-pushed the fix/self-user-refactoring branch from cb2c078 to 952df49 Compare January 15, 2025 13:44
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 36.20690% with 37 lines in your changes missing coverage. Please review.

Project coverage is 54.44%. Comparing base (b304f30) to head (f1b3ef1).

Files with missing lines Patch % Lines
.../com/wire/kalium/logic/data/user/UserRepository.kt 48.83% 16 Missing and 6 partials ⚠️
...alium/logic/feature/user/ObserveSelfUserUseCase.kt 0.00% 7 Missing ⚠️
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 0.00% 5 Missing ⚠️
...re/kalium/logic/feature/user/GetSelfUserUseCase.kt 0.00% 2 Missing ⚠️
...in/com/wire/kalium/logic/feature/user/UserScope.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3229      +/-   ##
===========================================
- Coverage    54.48%   54.44%   -0.04%     
===========================================
  Files         1269     1270       +1     
  Lines        36958    36984      +26     
  Branches      3745     3753       +8     
===========================================
+ Hits         20135    20136       +1     
- Misses       15410    15430      +20     
- Partials      1413     1418       +5     
Files with missing lines Coverage Δ
.../kotlin/com/wire/kalium/persistence/dao/UserDAO.kt 96.33% <ø> (ø)
...in/com/wire/kalium/logic/feature/user/UserScope.kt 0.00% <0.00%> (ø)
...re/kalium/logic/feature/user/GetSelfUserUseCase.kt 0.00% <0.00%> (ø)
...lin/com/wire/kalium/persistence/dao/UserDAOImpl.kt 51.29% <0.00%> (-1.18%) ⬇️
...alium/logic/feature/user/ObserveSelfUserUseCase.kt 0.00% <0.00%> (ø)
.../com/wire/kalium/logic/data/user/UserRepository.kt 66.28% <48.83%> (-1.07%) ⬇️

... 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 b304f30...f1b3ef1. Read the comment docs.

@sbakhtiarov sbakhtiarov added this pull request to the merge queue Jan 17, 2025
Merged via the queue into develop with commit bbddfe5 Jan 17, 2025
23 checks passed
@sbakhtiarov sbakhtiarov deleted the fix/self-user-refactoring branch January 17, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. 🚨 Potential breaking changes 👕 size: M type: bug / fix 🐞
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants