diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-24 13:36:47 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-04-15 09:49:35 +0200 |
commit | b211106695bb82f6c32e53306081b5262c3d109d (patch) | |
tree | fa187de1c33b0956665f5362e29af6b0f6d8bb57 /server/initializers/database.ts | |
parent | 69d48ee30c9d47cddf0c3c047dc99a99dcb6e894 (diff) | |
download | PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.gz PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.zst PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.zip |
Support video views/viewers stats in server
* Add "currentTime" and "event" body params to view endpoint
* Merge watching and view endpoints
* Introduce WatchAction AP activity
* Add tables to store viewer information of local videos
* Add endpoints to fetch video views/viewers stats of local videos
* Refactor views/viewers handlers
* Support "views" and "viewers" counters for both VOD and live videos
Diffstat (limited to 'server/initializers/database.ts')
-rw-r--r-- | server/initializers/database.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 0e690f6ae..7a7ba61f4 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -1,10 +1,14 @@ | |||
1 | import { QueryTypes, Transaction } from 'sequelize' | 1 | import { QueryTypes, Transaction } from 'sequelize' |
2 | import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' | 2 | import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' |
3 | import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' | ||
3 | import { TrackerModel } from '@server/models/server/tracker' | 4 | import { TrackerModel } from '@server/models/server/tracker' |
4 | import { VideoTrackerModel } from '@server/models/server/video-tracker' | 5 | import { VideoTrackerModel } from '@server/models/server/video-tracker' |
5 | import { UserModel } from '@server/models/user/user' | 6 | import { UserModel } from '@server/models/user/user' |
6 | import { UserNotificationModel } from '@server/models/user/user-notification' | 7 | import { UserNotificationModel } from '@server/models/user/user-notification' |
7 | import { UserVideoHistoryModel } from '@server/models/user/user-video-history' | 8 | import { UserVideoHistoryModel } from '@server/models/user/user-video-history' |
9 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' | ||
10 | import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' | ||
11 | import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section' | ||
8 | import { isTestInstance } from '../helpers/core-utils' | 12 | import { isTestInstance } from '../helpers/core-utils' |
9 | import { logger } from '../helpers/logger' | 13 | import { logger } from '../helpers/logger' |
10 | import { AbuseModel } from '../models/abuse/abuse' | 14 | import { AbuseModel } from '../models/abuse/abuse' |
@@ -42,10 +46,8 @@ import { VideoPlaylistElementModel } from '../models/video/video-playlist-elemen | |||
42 | import { VideoShareModel } from '../models/video/video-share' | 46 | import { VideoShareModel } from '../models/video/video-share' |
43 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 47 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
44 | import { VideoTagModel } from '../models/video/video-tag' | 48 | import { VideoTagModel } from '../models/video/video-tag' |
45 | import { VideoViewModel } from '../models/video/video-view' | 49 | import { VideoViewModel } from '../models/view/video-view' |
46 | import { CONFIG } from './config' | 50 | import { CONFIG } from './config' |
47 | import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' | ||
48 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' | ||
49 | 51 | ||
50 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string | 52 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string |
51 | 53 | ||
@@ -140,6 +142,8 @@ async function initDatabaseModels (silent: boolean) { | |||
140 | VideoStreamingPlaylistModel, | 142 | VideoStreamingPlaylistModel, |
141 | VideoPlaylistModel, | 143 | VideoPlaylistModel, |
142 | VideoPlaylistElementModel, | 144 | VideoPlaylistElementModel, |
145 | LocalVideoViewerModel, | ||
146 | LocalVideoViewerWatchSectionModel, | ||
143 | ThumbnailModel, | 147 | ThumbnailModel, |
144 | TrackerModel, | 148 | TrackerModel, |
145 | VideoTrackerModel, | 149 | VideoTrackerModel, |