Added "time taken" info for Statistics menu

This commit is contained in:
Bobby Wibowo 2020-08-24 08:08:21 +07:00
parent 1c7bff20d9
commit 65847232c4
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
2 changed files with 11 additions and 1 deletions

View File

@ -596,6 +596,7 @@ self.stats = async (req, res, next) => {
if (!isadmin) return res.status(403).end()
try {
const hrstart = process.hrtime()
const stats = {}
const os = await si.osInfo()
@ -933,7 +934,7 @@ self.stats = async (req, res, next) => {
statsCache.albums.generating = false
}
return res.json({ success: true, stats })
return res.json({ success: true, stats, hrtime: process.hrtime(hrstart) })
} catch (error) {
logger.error(error)
// Reset generating state when encountering any errors

View File

@ -2901,6 +2901,15 @@ page.getStatistics = (params = {}) => {
`
}
if (Array.isArray(response.data.hrtime))
content += `
<article class="message is-size-7">
<div class="message-body has-text-left">
Time taken: ${response.data.hrtime[0]}s ${Math.ceil(response.data.hrtime[1] / 1000000)}ms.
</div>
</article>
`
page.dom.innerHTML = content
page.fadeAndScroll()
page.updateTrigger(params.trigger, 'active')