squashing the bugs

This commit is contained in:
Matt Hill
2021-10-05 11:46:49 -06:00
committed by Aiden McClelland
parent 7756841b1e
commit d47dd28384
19 changed files with 122 additions and 175 deletions

View File

@@ -1,4 +1,5 @@
import { Pipe, PipeTransform } from '@angular/core'
import { PackageLoadingService, ProgressData } from '../services/package-loading.service'
import { InstallProgress } from '../services/patch-db/data-model'
@Pipe({
@@ -6,37 +7,11 @@ import { InstallProgress } from '../services/patch-db/data-model'
})
export class InstallState implements PipeTransform {
constructor (
private readonly pkgLoading: PackageLoadingService,
) { }
transform (loadData: InstallProgress): ProgressData {
let { downloaded, validated, unpacked, size, 'download-complete': downloadComplete, 'validation-complete': validationComplete, 'unpack-complete': unpackComplete } = loadData
downloaded = downloadComplete ? size : downloaded
validated = validationComplete ? size : validated
unpacked = unpackComplete ? size : unpacked
const downloadWeight = 1
const validateWeight = .2
const unpackWeight = .7
const numerator = Math.floor(
downloadWeight * downloaded +
validateWeight * validated +
unpackWeight * unpacked)
const denominator = Math.floor(loadData.size * (downloadWeight + validateWeight + unpackWeight))
return {
totalProgress: Math.round(100 * numerator / denominator),
downloadProgress: Math.round(100 * downloaded / size),
validateProgress: Math.round(100 * validated / size),
unpackProgress: Math.round(100 * unpacked / size),
isComplete: downloadComplete && validationComplete && unpackComplete,
}
return this.pkgLoading.transform(loadData)
}
}
export interface ProgressData {
totalProgress: number
downloadProgress: number
validateProgress: number
unpackProgress: number
isComplete: boolean
}