mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-14 15:59:38 +00:00
parent
8512d5e693
commit
1dec8ae122
13 changed files with 213 additions and 83 deletions
|
|
@ -18,7 +18,6 @@ class LibraryScan {
|
|||
this.startedAt = null
|
||||
this.finishedAt = null
|
||||
this.elapsed = null
|
||||
this.error = null
|
||||
|
||||
this.resultsMissing = 0
|
||||
this.resultsAdded = 0
|
||||
|
|
@ -55,22 +54,6 @@ class LibraryScan {
|
|||
get elapsedTimestamp() {
|
||||
return secondsToTimestamp(this.elapsed / 1000)
|
||||
}
|
||||
get getScanEmitData() {
|
||||
return {
|
||||
id: this.libraryId,
|
||||
type: this.type,
|
||||
name: this.libraryName,
|
||||
error: this.error,
|
||||
results: {
|
||||
added: this.resultsAdded,
|
||||
updated: this.resultsUpdated,
|
||||
missing: this.resultsMissing
|
||||
}
|
||||
}
|
||||
}
|
||||
get totalResults() {
|
||||
return this.resultsAdded + this.resultsUpdated + this.resultsMissing
|
||||
}
|
||||
get logFilename() {
|
||||
return date.format(new Date(), 'YYYY-MM-DD') + '_' + this.id + '.txt'
|
||||
}
|
||||
|
|
@ -79,10 +62,19 @@ class LibraryScan {
|
|||
if (this.resultsAdded) strs.push(`${this.resultsAdded} added`)
|
||||
if (this.resultsUpdated) strs.push(`${this.resultsUpdated} updated`)
|
||||
if (this.resultsMissing) strs.push(`${this.resultsMissing} missing`)
|
||||
const changesDetected = strs.length > 0 ? strs.join(', ') : 'No changes detected'
|
||||
const changesDetected = strs.length > 0 ? strs.join(', ') : 'No changes needed'
|
||||
const timeElapsed = `(${elapsedPretty(this.elapsed / 1000)})`
|
||||
const error = this.error ? `${this.error}. ` : ''
|
||||
return `${error}${changesDetected} ${timeElapsed}`
|
||||
return `${changesDetected} ${timeElapsed}`
|
||||
}
|
||||
|
||||
get scanResults() {
|
||||
return {
|
||||
added: this.resultsAdded,
|
||||
updated: this.resultsUpdated,
|
||||
missing: this.resultsMissing,
|
||||
elapsed: this.elapsed,
|
||||
text: this.scanResultsString
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
@ -93,7 +85,6 @@ class LibraryScan {
|
|||
startedAt: this.startedAt,
|
||||
finishedAt: this.finishedAt,
|
||||
elapsed: this.elapsed,
|
||||
error: this.error,
|
||||
resultsAdded: this.resultsAdded,
|
||||
resultsUpdated: this.resultsUpdated,
|
||||
resultsMissing: this.resultsMissing
|
||||
|
|
@ -113,14 +104,9 @@ class LibraryScan {
|
|||
this.startedAt = Date.now()
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} error
|
||||
*/
|
||||
setComplete(error = null) {
|
||||
setComplete() {
|
||||
this.finishedAt = Date.now()
|
||||
this.elapsed = this.finishedAt - this.startedAt
|
||||
this.error = error
|
||||
}
|
||||
|
||||
getLogLevelString(level) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue