mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-22 11:54:32 +02:00
Add:All listening sessions config page
This commit is contained in:
parent
2d5e4ebcf0
commit
5cd343cb01
7 changed files with 261 additions and 13 deletions
|
@ -174,6 +174,7 @@ class ApiRouter {
|
|||
//
|
||||
// Playback Session Routes
|
||||
//
|
||||
this.router.get('/sessions', SessionController.getAllWithUserData.bind(this))
|
||||
this.router.get('/session/:id', SessionController.middleware.bind(this), SessionController.getSession.bind(this))
|
||||
this.router.post('/session/:id/sync', SessionController.middleware.bind(this), SessionController.sync.bind(this))
|
||||
this.router.post('/session/:id/close', SessionController.middleware.bind(this), SessionController.close.bind(this))
|
||||
|
@ -310,6 +311,19 @@ class ApiRouter {
|
|||
return userSessions.sort((a, b) => b.updatedAt - a.updatedAt)
|
||||
}
|
||||
|
||||
async getAllSessionsWithUserData() {
|
||||
var sessions = await this.db.getAllSessions()
|
||||
sessions.sort((a, b) => b.updatedAt - a.updatedAt)
|
||||
return sessions.map(se => {
|
||||
var user = this.db.users.find(u => u.id === se.userId)
|
||||
var _se = {
|
||||
...se,
|
||||
user: user ? { id: user.id, username: user.username } : null
|
||||
}
|
||||
return _se
|
||||
})
|
||||
}
|
||||
|
||||
async getUserListeningStatsHelpers(userId) {
|
||||
const today = date.format(new Date(), 'YYYY-MM-DD')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue