mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: show analytics data page by page
This commit is contained in:
1 parent
9200336b49
commit
ac31ca8659
9 files changed
+87
-12
No files matched your search
@@ -1,8 +1,21 @@
|
||||
import { sessionList, sessionDetail } from '../models/sessions.js'
|
||||
import { sessionCount, sessionList, sessionDetail } from '../models/sessions.js'
|
||||
|
||||
export async function sessionListController(req, res) {
|
||||
const sessions = await sessionList()
|
||||
res.render('sessions', { sessions })
|
||||
const pageNumber = req.query.page || 1
|
||||
const itemsPerPage = 100
|
||||
|
||||
try {
|
||||
const totalSessions = await sessionCount()
|
||||
const maxPages = Math.ceil(totalSessions / itemsPerPage)
|
||||
|
||||
const sessions = await sessionList(pageNumber, itemsPerPage)
|
||||
|
||||
const pages = Array.from({ length: maxPages }, (_, index) => index + 1)
|
||||
|
||||
res.render('sessions', { sessions, pages })
|
||||
} catch (error) {
|
||||
res.status(500).send('Error fetching session data')
|
||||
}
|
||||
}
|
||||
|
||||
export async function sessionDetailController(req, res) {
|
||||
|
||||
Reference in new issue
Block a user