Update:Listening sessions table for multi-select, sorting and rows per page

- Updated get all sessions API endpoint to include sorting
- Added sessions API endpoint for batch deleting
This commit is contained in:
advplyr 2023-12-21 13:52:42 -06:00
parent 46ec59c74e
commit 76119445a3
25 changed files with 375 additions and 62 deletions

View file

@ -221,6 +221,7 @@ class ApiRouter {
this.router.get('/sessions', SessionController.getAllWithUserData.bind(this))
this.router.delete('/sessions/:id', SessionController.middleware.bind(this), SessionController.delete.bind(this))
this.router.get('/sessions/open', SessionController.getOpenSessions.bind(this))
this.router.post('/sessions/batch/delete', SessionController.batchDelete.bind(this))
this.router.post('/session/local', SessionController.syncLocal.bind(this))
this.router.post('/session/local-all', SessionController.syncLocalSessions.bind(this))
// TODO: Update these endpoints because they are only for open playback sessions
@ -491,18 +492,6 @@ class ApiRouter {
return userSessions.sort((a, b) => b.updatedAt - a.updatedAt)
}
async getAllSessionsWithUserData() {
const sessions = await Database.getPlaybackSessions()
sessions.sort((a, b) => b.updatedAt - a.updatedAt)
const minifiedUserObjects = await Database.userModel.getMinifiedUserObjects()
return sessions.map(se => {
return {
...se,
user: minifiedUserObjects.find(u => u.id === se.userId) || null
}
})
}
async getUserListeningStatsHelpers(userId) {
const today = date.format(new Date(), 'YYYY-MM-DD')