Make storage stats consistent
This commit is contained in:
1 parent
0ca1f9d916
commit
5ffc8122d0
3 files changed
+11
-29
No files matched your search
@@ -12,7 +12,7 @@ pub async fn stats(ctx: Context<'_>) -> Result<(), Error> {
|
|||||||
);
|
);
|
||||||
let stats = web::archive_stats(&ctx.data().pool).await?;
|
let stats = web::archive_stats(&ctx.data().pool).await?;
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"# Archive Statistics\n## Messages\nArchived messages: {}\nArchived users: {}\nChannels: {}\nServers: {}\n## Storage usage\nTotal archive: {}\nMessages and metadata: {}\nAttachments: {}",
|
"# Archive Statistics\n## Messages\nArchived messages: {}\nArchived users: {}\nChannels: {}\nServers: {}\n## Storage usage\nArchived data: {}\nMessage content: {}\nAttachments: {}",
|
||||||
stats.messages,
|
stats.messages,
|
||||||
stats.users,
|
stats.users,
|
||||||
stats.channels,
|
stats.channels,
|
||||||
|
|||||||
+8
-26
@@ -1072,32 +1072,14 @@ pub async fn archive_stats(pool: &PgPool) -> Result<ArchiveStats, sqlx::Error> {
|
|||||||
(SELECT COUNT(*) FROM discord_users),
|
(SELECT COUNT(*) FROM discord_users),
|
||||||
(SELECT COUNT(*) FROM guilds),
|
(SELECT COUNT(*) FROM guilds),
|
||||||
(SELECT COUNT(*) FROM channels),
|
(SELECT COUNT(*) FROM channels),
|
||||||
pg_total_relation_size('guilds')
|
(SELECT COALESCE(SUM(OCTET_LENGTH(content)), 0)
|
||||||
+ pg_total_relation_size('channels')
|
FROM message_versions)
|
||||||
+ pg_total_relation_size('discord_users')
|
+ (SELECT COALESCE(SUM(OCTET_LENGTH(data)), 0)
|
||||||
+ pg_total_relation_size('discord_roles')
|
FROM attachments),
|
||||||
+ pg_total_relation_size('messages')
|
(SELECT COALESCE(SUM(OCTET_LENGTH(content)), 0)
|
||||||
+ pg_total_relation_size('message_versions')
|
FROM message_versions),
|
||||||
+ pg_total_relation_size('attachments')
|
(SELECT COALESCE(SUM(OCTET_LENGTH(data)), 0)
|
||||||
+ pg_total_relation_size('embeds')
|
FROM attachments);",
|
||||||
+ pg_total_relation_size('embed_fields')
|
|
||||||
+ pg_total_relation_size('guild_history')
|
|
||||||
+ pg_total_relation_size('channel_history')
|
|
||||||
+ pg_total_relation_size('discord_user_history')
|
|
||||||
+ pg_total_relation_size('guild_users'),
|
|
||||||
pg_total_relation_size('messages')
|
|
||||||
+ pg_total_relation_size('message_versions')
|
|
||||||
+ pg_total_relation_size('guilds')
|
|
||||||
+ pg_total_relation_size('channels')
|
|
||||||
+ pg_total_relation_size('discord_users')
|
|
||||||
+ pg_total_relation_size('discord_roles')
|
|
||||||
+ pg_total_relation_size('embeds')
|
|
||||||
+ pg_total_relation_size('embed_fields')
|
|
||||||
+ pg_total_relation_size('guild_history')
|
|
||||||
+ pg_total_relation_size('channel_history')
|
|
||||||
+ pg_total_relation_size('discord_user_history')
|
|
||||||
+ pg_total_relation_size('guild_users'),
|
|
||||||
pg_total_relation_size('attachments');",
|
|
||||||
)
|
)
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
<p>Archived {{message_count}} messages from {{user_count}} users across {{channel_count}} channels on {{server_count}} servers.</p>
|
<p>Archived {{message_count}} messages from {{user_count}} users across {{channel_count}} channels on {{server_count}} servers.</p>
|
||||||
<h3>Storage usage</h3>
|
<h3>Storage usage</h3>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Total archive</dt><dd>{{total_storage}}</dd>
|
<dt>Archived data</dt><dd>{{total_storage}}</dd>
|
||||||
<dt>Messages and metadata</dt><dd>{{message_storage}}</dd>
|
<dt>Message content</dt><dd>{{message_storage}}</dd>
|
||||||
<dt>Attachments</dt><dd>{{attachment_storage}}</dd>
|
<dt>Attachments</dt><dd>{{attachment_storage}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user