mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Add subdivision to viewer stats
This commit is contained in:
parent
4437ae0fd3
commit
4cbea51255
18 changed files with 243 additions and 61 deletions
|
@ -27,6 +27,7 @@ type LocalViewerStats = {
|
|||
watchTime: number
|
||||
|
||||
country: string
|
||||
subdivisionName: string
|
||||
|
||||
videoId: number
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ export class VideoViewerStats {
|
|||
}
|
||||
|
||||
if (!stats) {
|
||||
const country = await GeoIP.Instance.safeCountryISOLookup(ip)
|
||||
const { country, subdivisionName } = await GeoIP.Instance.safeIPISOLookup(ip)
|
||||
|
||||
stats = {
|
||||
firstUpdated: nowMs,
|
||||
|
@ -96,6 +97,8 @@ export class VideoViewerStats {
|
|||
watchTime: 0,
|
||||
|
||||
country,
|
||||
subdivisionName,
|
||||
|
||||
videoId: video.id
|
||||
}
|
||||
}
|
||||
|
@ -180,6 +183,7 @@ export class VideoViewerStats {
|
|||
endDate: new Date(stats.lastUpdated),
|
||||
watchTime: stats.watchTime,
|
||||
country: stats.country,
|
||||
subdivisionName: stats.subdivisionName,
|
||||
videoId: video.id
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue