Skip to content

Commit fa6a693

Browse files
committed
REMOVE unused statistics
1 parent 69dd8fe commit fa6a693

File tree

1 file changed

+0
-103
lines changed

1 file changed

+0
-103
lines changed

src/self_reporting.rs

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,12 @@ const SELF_REPORTING_BOT_VCARD: &str = include_str!("../assets/self-reporting-bo
2525
#[derive(Serialize)]
2626
struct Statistics {
2727
core_version: String,
28-
num_msgs: u32,
29-
num_chats: u32,
30-
db_size: u64,
3128
key_created: i64,
32-
chat_numbers: ChatNumbers,
3329
self_reporting_id: String,
3430
contact_stats: Vec<ContactStat>,
3531
message_stats: MessageStats,
3632
securejoin_source_stats: SecurejoinSourceStats,
3733
}
38-
#[derive(Default, Serialize)]
39-
struct ChatNumbers {
40-
protected: u32,
41-
protection_broken: u32,
42-
opportunistic_dc: u32,
43-
opportunistic_mua: u32,
44-
unencrypted_dc: u32,
45-
unencrypted_mua: u32,
46-
}
4734

4835
#[derive(Serialize, PartialEq)]
4936
enum VerifiedStatus {
@@ -158,98 +145,12 @@ See TODO[blog post] for more information."
158145
}
159146

160147
async fn get_self_report(context: &Context, last_selfreport_time: i64) -> Result<String> {
161-
let num_msgs: u32 = context
162-
.sql
163-
.query_get_value(
164-
"SELECT COUNT(*) FROM msgs WHERE hidden=0 AND chat_id!=?",
165-
(DC_CHAT_ID_TRASH,),
166-
)
167-
.await?
168-
.unwrap_or_default();
169-
170-
let num_chats: u32 = context
171-
.sql
172-
.query_get_value("SELECT COUNT(*) FROM chats WHERE id>9 AND blocked!=1", ())
173-
.await?
174-
.unwrap_or_default();
175-
176-
let db_size = tokio::fs::metadata(&context.sql.dbfile).await?.len();
177-
178148
let key_created = load_self_public_key(context)
179149
.await?
180150
.primary_key
181151
.created_at()
182152
.timestamp();
183153

184-
// how many of the chats active in the last months are:
185-
// - protected
186-
// - protection-broken
187-
// - opportunistic-encrypted and the contact uses Delta Chat
188-
// - opportunistic-encrypted and the contact uses a classical MUA
189-
// - unencrypted and the contact uses Delta Chat
190-
// - unencrypted and the contact uses a classical MUA
191-
let three_months_ago = time().saturating_sub(3600 * 24 * 30 * 3);
192-
let chat_numbers = context
193-
.sql
194-
.query_map(
195-
// For all chats, query:
196-
// - Whether it's protected, i.e. has a green checkmark
197-
// and only allows messages with verified encryption
198-
// - Whether the latest message is encrypted (stored in the param)
199-
// - Whether the latest message was sent by Delta Chat (stored in msgrmsg)
200-
// TODO: Maybe should only query incoming messages, because outgoing messages are always sent by DC
201-
"SELECT c.protected, m.param, m.msgrmsg
202-
FROM chats c
203-
JOIN msgs m
204-
ON c.id=m.chat_id
205-
AND m.id=(
206-
SELECT id
207-
FROM msgs
208-
WHERE chat_id=c.id
209-
AND hidden=0 -- Some control messages are hidden, i.e. not actually shown to the user
210-
AND download_state=? -- If a message isn't fully downloaded, we don't know whether it's encrypted
211-
AND to_id!=? -- Some messages are informational messages, rather than actual message content
212-
ORDER BY timestamp DESC, id DESC LIMIT 1) -- Only query the latest message
213-
WHERE c.id>9
214-
AND (c.blocked=0 OR c.blocked=2)
215-
AND IFNULL(m.timestamp,c.created_timestamp) > ?
216-
GROUP BY c.id",
217-
(DownloadState::Done, ContactId::INFO, three_months_ago),
218-
|row| {
219-
let protected: ProtectionStatus = row.get(0)?;
220-
let message_param: Params = row.get::<_, String>(1)?.parse().unwrap_or_default();
221-
let is_dc_message: bool = row.get(2)?;
222-
Ok((protected, message_param, is_dc_message))
223-
},
224-
|rows| {
225-
let mut chats = ChatNumbers::default();
226-
for row in rows {
227-
let (protected, message_param, is_dc_message) = row?;
228-
let encrypted = message_param
229-
.get_bool(Param::GuaranteeE2ee)
230-
.unwrap_or(false);
231-
232-
if protected == ProtectionStatus::Protected {
233-
chats.protected += 1;
234-
} else if protected == ProtectionStatus::ProtectionBroken {
235-
chats.protection_broken += 1;
236-
} else if encrypted {
237-
if is_dc_message {
238-
chats.opportunistic_dc += 1;
239-
} else {
240-
chats.opportunistic_mua += 1;
241-
}
242-
} else if is_dc_message {
243-
chats.unencrypted_dc += 1;
244-
} else {
245-
chats.unencrypted_mua += 1;
246-
}
247-
}
248-
Ok(chats)
249-
},
250-
)
251-
.await?;
252-
253154
let self_reporting_id = match context.get_config(Config::SelfReportingId).await? {
254155
Some(id) => id,
255156
None => {
@@ -262,11 +163,7 @@ async fn get_self_report(context: &Context, last_selfreport_time: i64) -> Result
262163
};
263164
let statistics = Statistics {
264165
core_version: get_version_str().to_string(),
265-
num_msgs,
266-
num_chats,
267-
db_size,
268166
key_created,
269-
chat_numbers,
270167
self_reporting_id,
271168
contact_stats: get_contact_stats(context).await?,
272169
message_stats: get_message_stats(context, last_selfreport_time).await?,

0 commit comments

Comments
 (0)