Fix Backup info size display (#7540)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

This commit is contained in:
Andrey Sobolev 2024-12-24 20:16:45 +07:00 committed by GitHub
parent b9cb463bfc
commit 30edf4ea8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 38 additions and 12 deletions

View File

@ -10,6 +10,8 @@ export interface DocChunk {
idx: number
// _id => hash mapping
docs: DocInfo[]
size?: number // Estimated size of the chunk data
finished: boolean
}

View File

@ -25,6 +25,8 @@ import type { WorkspaceIdWithUrl } from './utils'
export interface DocInfo {
id: string
hash: string
size?: number
}
/**
* @public

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { groupByArray, type BaseWorkspaceInfo } from '@hcengineering/core'
import { groupByArray, isActiveMode, type BaseWorkspaceInfo } from '@hcengineering/core'
import { getEmbeddedLabel } from '@hcengineering/platform'
import { isAdminUser } from '@hcengineering/presentation'
import {
@ -84,6 +84,9 @@
{#if isAdmin}
<div class="anticrm-panel flex-row flex-grow p-5">
<div class="fs-title p-3">Workspaces administration panel</div>
<div class="fs-title p-3">
Workspaces: {workspaces.length} active: {workspaces.filter((it) => isActiveMode(it.mode)).length}
</div>
<div class="fs-title p-3 flex-no-shrink">
<SearchEdit bind:value={search} width={'100%'} />
</div>
@ -174,7 +177,7 @@
</span>
<span class="label overflow-label" style:width={'10rem'}>
{workspace.mode}
{workspace.mode ?? '-'}
</span>
<span class="label overflow-label" style:width={'2rem'}>
@ -191,7 +194,10 @@
</span>
<span class="flex flex-between" style:width={'5rem'}>
{#if workspace.backupInfo != null}
{@const sz = workspace.backupInfo.dataSize + workspace.backupInfo.blobsSize}
{@const sz = Math.max(
workspace.backupInfo.backupSize,
workspace.backupInfo.dataSize + workspace.backupInfo.blobsSize
)}
{@const szGb = Math.round((sz * 100) / 1024) / 100}
{#if szGb > 0}
{Math.round((sz * 100) / 1024) / 100}Gb

View File

@ -215,6 +215,7 @@ function getWorkspaceSize (it: Pick<Workspace, 'backupInfo'>): number {
let sz = 0
sz += it.backupInfo?.dataSize ?? 0
sz += it.backupInfo?.blobsSize ?? 0
sz += it.backupInfo?.backupSize ?? 0
return sz
}

View File

@ -189,7 +189,10 @@
{#if isAdmin && ws.lastVisit != null && ws.lastVisit !== 0}
<div class="text-sm">
{#if ws.backupInfo != null}
{@const sz = ws.backupInfo.dataSize + ws.backupInfo.blobsSize}
{@const sz = Math.max(
ws.backupInfo.backupSize,
ws.backupInfo.dataSize + ws.backupInfo.blobsSize
)}
{@const szGb = Math.round((sz * 100) / 1024) / 100}
{#if szGb > 0}
{Math.round((sz * 100) / 1024) / 100}Gb -

View File

@ -897,6 +897,12 @@ export async function backup (
while (true) {
try {
const currentChunk = await ctx.with('loadChunk', {}, () => connection.loadChunk(domain, idx))
if (domain === DOMAIN_BLOB) {
result.blobsSize += currentChunk.size ?? 0
} else {
result.dataSize += currentChunk.size ?? 0
}
idx = currentChunk.idx
ops++
@ -1152,12 +1158,6 @@ export async function backup (
break
}
if (domain === DOMAIN_BLOB) {
result.blobsSize += (d as Blob).size
} else {
result.dataSize += JSON.stringify(d).length
}
function processChanges (d: Doc, error: boolean = false): void {
processed++
// Move processed document to processedChanges
@ -1777,6 +1777,7 @@ export async function restore (
let loaded = 0
let el = 0
let chunks = 0
let dataSize = 0
try {
while (true) {
if (opt.progress !== undefined) {
@ -1784,6 +1785,7 @@ export async function restore (
}
const st = Date.now()
const it = await connection.loadChunk(c, idx)
dataSize += it.size ?? 0
chunks++
idx = it.idx
@ -1808,7 +1810,12 @@ export async function restore (
await connection.closeChunk(idx)
}
}
ctx.info('loaded', { loaded, workspace: workspaceId.name })
ctx.info('loaded', {
domain: c,
loaded,
workspace: workspaceId.name,
dataSize: Math.round((dataSize / (1024 * 1024)) * 100) / 100
})
ctx.info('\tcompare documents', {
size: changeset.size,
serverSize: serverChangeset.size,

View File

@ -52,6 +52,7 @@ export class BackupClientOps {
return ctx.with('load-chunk', {}, async (ctx) => {
idx = idx ?? this.idIndex++
let chunk: ChunkInfo | undefined = this.chunkInfo.get(idx)
let size = 0
if (chunk !== undefined) {
chunk.index++
if (chunk.finished === undefined || chunk.finished) {
@ -74,12 +75,16 @@ export class BackupClientOps {
break
}
docs.push(..._docs)
for (const d of _docs) {
size += d.size ?? 0
}
}
return {
idx,
docs,
finished: chunk.finished
finished: chunk.finished,
size
}
})
}