-
Notifications
You must be signed in to change notification settings - Fork 6
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: New user properties for Analytics [WPB-16121] #3312
base: develop
Are you sure you want to change the base?
Conversation
|
|
Branch | feat/new_user_properties_for_analytics |
Testbed | ubuntu-latest |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholds
flag.
Click to view all benchmark results
Benchmark | Latency | microseconds (µs) |
---|---|---|
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles | 📈 view plot | 692.81 µs |
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory | 📈 view plot | 523,504.76 µs |
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark | 📈 view plot | 1,344,936.02 µs |
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark | 📈 view plot | 26,904.02 µs |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3312 +/- ##
===========================================
+ Coverage 50.72% 50.76% +0.03%
===========================================
Files 1610 1612 +2
Lines 58206 58317 +111
Branches 5255 5272 +17
===========================================
+ Hits 29525 29603 +78
- Misses 26649 26670 +21
- Partials 2032 2044 +12 see 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportBranch report: ✅ 0 Failed, 3435 Passed, 110 Skipped, 1m 4.1s Total Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one question about where to add the new functions
override suspend fun getContactsAmountCached(): Either<StorageFailure, Int> = wrapStorageRequest { | ||
metadataDAO.valueByKey(CONTACTS_AMOUNT_KEY)?.toInt() | ||
} | ||
|
||
override suspend fun getTeamMembersAmountCached(): Either<StorageFailure, Int> = wrapStorageRequest { | ||
metadataDAO.valueByKey(TEAM_MEMBERS_AMOUNT_KEY)?.toInt() | ||
} | ||
|
||
override suspend fun setContactsAmountCached(amount: Int) = | ||
metadataDAO.insertValue(CONTACTS_AMOUNT_KEY, amount.toString()) | ||
|
||
override suspend fun setTeamMembersAmountCached(amount: Int) = | ||
metadataDAO.insertValue(TEAM_MEMBERS_AMOUNT_KEY, amount.toString()) | ||
|
||
override suspend fun getLastContactsDateUpdateDate(): Either<StorageFailure, Instant> = wrapStorageRequest { | ||
metadataDAO.valueByKey(LAST_CONTACTS_UPDATE_KEY)?.let { Instant.parse(it) } | ||
} | ||
|
||
override suspend fun setContactsAmountCachingDate(date: Instant) = | ||
metadataDAO.insertValue(LAST_CONTACTS_UPDATE_KEY, date.toString()) | ||
|
||
override suspend fun countContactsAmount(): Either<StorageFailure, Int> = wrapStorageRequest { | ||
userDAO.countContactsAmount() | ||
} | ||
|
||
override suspend fun countTeamMembersAmount(): Either<StorageFailure, Int> = wrapStorageRequest { | ||
userDAO.countTeamMembersAmount() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can those be moved out of the UserRepository to their own, maybe a AnalyticsRepo ?
SELECT COUNT() FROM User WHERE User.team = (SELECT User.team FROM User WHERE User.qualified_id = (SELECT id FROM SelfUser)) | ||
AND qualified_id != (SELECT id FROM SelfUser); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a simple COUNT() FROM User WHERE User.team = :team_id and pass the team id form the cached one in the session scope, is a simpler way to do it
@@ -299,3 +299,10 @@ UPDATE User SET team = ? WHERE qualified_id = ?; | |||
selectNameByMessageId: | |||
SELECT name FROM User | |||
WHERE qualified_id = (SELECT Message.sender_user_id FROM Message WHERE Message.id = :messageId AND Message.conversation_id = :conversationId); | |||
|
|||
selectContactsAmount: | |||
SELECT COUNT() FROM User WHERE User.connection_status = 'ACCEPTED' AND qualified_id != (SELECT id FROM SelfUser); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here there is no need to exclude self, just count accepted to make it simpler
@@ -299,3 +299,10 @@ UPDATE User SET team = ? WHERE qualified_id = ?; | |||
selectNameByMessageId: | |||
SELECT name FROM User | |||
WHERE qualified_id = (SELECT Message.sender_user_id FROM Message WHERE Message.id = :messageId AND Message.conversation_id = :conversationId); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we would need to add index to the connection status in this case to support a wider range of use cases we can use
CREATE INDEX idx_user_connection_deleted_handle ON User (connection_status, deleted, handle);
this will make it also faster to do search 2 birds in 1 stone
What's new in this PR?
Need to implement new user properties 2 of them: amount of users contacts AND amount of team member in users team.
Solutions
MetaDataDao
. That caches should refresh after 7 days.GetAnalyticsContactsDataUseCase
for getting cached values and combining all the necessary data intoAnalyticsContactsData
data classUpdateContactsAmountsCacheUseCase
for refreshing the cache and run it inUserSessionScope