mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 05:12:11 +00:00
add missing statistic
This commit is contained in:
parent
78cdb9244c
commit
d52f1eefea
2 changed files with 34 additions and 0 deletions
|
|
@ -126,6 +126,35 @@ class KeyVerificationDao extends DatabaseAccessor<TwonlyDB>
|
|||
return rows.length;
|
||||
}
|
||||
|
||||
Future<int> getCountOfContactsWithVerificationBadge() async {
|
||||
final kv = keyVerifications;
|
||||
final ur = userDiscoveryUserRelations;
|
||||
|
||||
final query = selectOnly(ur, distinct: true)
|
||||
..addColumns([ur.announcedUserId])
|
||||
..join([
|
||||
innerJoin(contacts, contacts.userId.equalsExp(ur.fromContactId)),
|
||||
innerJoin(kv, kv.contactId.equalsExp(ur.fromContactId)),
|
||||
])
|
||||
..where(
|
||||
ur.publicKeyVerifiedTimestamp.isNotNull() &
|
||||
ur.announcedUserId.equalsExp(ur.fromContactId).not(),
|
||||
)
|
||||
..groupBy([ur.announcedUserId]);
|
||||
|
||||
final rows = await query.get();
|
||||
final transferredIds = rows.map((r) => r.read(ur.announcedUserId)!).toSet();
|
||||
|
||||
final directVerifications = await select(kv).get();
|
||||
final directIds = directVerifications.map((v) => v.contactId).toSet();
|
||||
|
||||
// Reduce transferred contacts where announcedUserId is already in KeyVerifications
|
||||
transferredIds.removeWhere(directIds.contains);
|
||||
|
||||
// Add count of all users who are in the KeyVerification table
|
||||
return transferredIds.length + directIds.length;
|
||||
}
|
||||
|
||||
Stream<VerificationStatus> watchAllGroupMembersVerified(String groupId) {
|
||||
final gm = groupMembers;
|
||||
final directKv = alias(keyVerifications, 'directKv');
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ Future<void> handleUserStudyUpload() async {
|
|||
final udVerifiedByContactsCount = await twonlyDB.keyVerificationDao
|
||||
.getTransferredTrustVerificationsCount();
|
||||
|
||||
final totalContactsWithVerificationBadge = await twonlyDB.keyVerificationDao
|
||||
.getCountOfContactsWithVerificationBadge();
|
||||
|
||||
final udFriendsShared = await twonlyDB.contactsDao
|
||||
.getContactsAnnouncedViaUserDiscovery();
|
||||
|
||||
|
|
@ -87,6 +90,8 @@ Future<void> handleUserStudyUpload() async {
|
|||
|
||||
'accepted_contacts': contacts.where((c) => c.accepted).length,
|
||||
'verified_contacts': verifications.length,
|
||||
'total_contacts_with_verification_badge':
|
||||
totalContactsWithVerificationBadge,
|
||||
'verified_contacts_via_migrated_from_old_version': verifications.values
|
||||
.where((c) => c == VerificationType.migratedFromOldVersion)
|
||||
.length,
|
||||
|
|
|
|||
Loading…
Reference in a new issue