mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Fix:Local playback session store date/dayOfWeek string to be used in stats
This commit is contained in:
parent
caea6c6371
commit
c6323f8ad9
@ -154,7 +154,7 @@ export default {
|
|||||||
|
|
||||||
this.showingTooltipIndex = index
|
this.showingTooltipIndex = index
|
||||||
this.tooltipEl.style.display = 'block'
|
this.tooltipEl.style.display = 'block'
|
||||||
this.tooltipTextEl.innerHTML = block.value ? `<strong>${block.value} minutes listening</strong> on ${block.datePretty}` : `No listening sessions on ${block.datePretty}`
|
this.tooltipTextEl.innerHTML = block.value ? `<strong>${this.$elapsedPretty(block.value, true)} listening</strong> on ${block.datePretty}` : `No listening sessions on ${block.datePretty}`
|
||||||
|
|
||||||
const calculateRect = this.tooltipEl.getBoundingClientRect()
|
const calculateRect = this.tooltipEl.getBoundingClientRect()
|
||||||
|
|
||||||
|
@ -40,20 +40,20 @@ Vue.prototype.$bytesPretty = (bytes, decimals = 2) => {
|
|||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$elapsedPretty = (seconds) => {
|
Vue.prototype.$elapsedPretty = (seconds, useFullNames = false) => {
|
||||||
if (seconds < 60) {
|
if (seconds < 60) {
|
||||||
return `${Math.floor(seconds)} sec`
|
return `${Math.floor(seconds)} sec${useFullNames ? 'onds' : ''}`
|
||||||
}
|
}
|
||||||
var minutes = Math.floor(seconds / 60)
|
var minutes = Math.floor(seconds / 60)
|
||||||
if (minutes < 70) {
|
if (minutes < 70) {
|
||||||
return `${minutes} min`
|
return `${minutes} min${useFullNames ? `ute${minutes === 1 ? '' : 's'}` : ''}`
|
||||||
}
|
}
|
||||||
var hours = Math.floor(minutes / 60)
|
var hours = Math.floor(minutes / 60)
|
||||||
minutes -= hours * 60
|
minutes -= hours * 60
|
||||||
if (!minutes) {
|
if (!minutes) {
|
||||||
return `${hours} hr`
|
return `${hours} ${useFullNames ? 'hours' : 'hr'}`
|
||||||
}
|
}
|
||||||
return `${hours} hr ${minutes} min`
|
return `${hours} ${useFullNames ? `hour${hours === 1 ? '' : 's'}` : 'hr'} ${minutes} ${useFullNames ? `minute${minutes === 1 ? '' : 's'}` : 'min'}`
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$secondsToTimestamp = (seconds) => {
|
Vue.prototype.$secondsToTimestamp = (seconds) => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
|
const date = require('date-and-time')
|
||||||
const { PlayMethod } = require('../utils/constants')
|
const { PlayMethod } = require('../utils/constants')
|
||||||
const PlaybackSession = require('../objects/PlaybackSession')
|
const PlaybackSession = require('../objects/PlaybackSession')
|
||||||
const Stream = require('../objects/Stream')
|
const Stream = require('../objects/Stream')
|
||||||
@ -53,6 +54,8 @@ class PlaybackSessionManager {
|
|||||||
} else {
|
} else {
|
||||||
session.timeListening = sessionJson.timeListening
|
session.timeListening = sessionJson.timeListening
|
||||||
session.updatedAt = sessionJson.updatedAt
|
session.updatedAt = sessionJson.updatedAt
|
||||||
|
session.date = date.format(new Date(), 'YYYY-MM-DD')
|
||||||
|
session.dayOfWeek = date.format(new Date(), 'dddd')
|
||||||
await this.db.updateEntity('session', session)
|
await this.db.updateEntity('session', session)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user