aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/view/local-video-viewer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/view/local-video-viewer.ts')
-rw-r--r--server/models/view/local-video-viewer.ts14
1 files changed, 1 insertions, 13 deletions
diff --git a/server/models/view/local-video-viewer.ts b/server/models/view/local-video-viewer.ts
index b6ddcbb57..5928ba5f6 100644
--- a/server/models/view/local-video-viewer.ts
+++ b/server/models/view/local-video-viewer.ts
@@ -134,9 +134,6 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
134 FETCH FIRST 1 ROW ONLY` 134 FETCH FIRST 1 ROW ONLY`
135 const watchPeakPromise = LocalVideoViewerModel.sequelize.query<any>(watchPeakQuery, options) 135 const watchPeakPromise = LocalVideoViewerModel.sequelize.query<any>(watchPeakQuery, options)
136 136
137 const commentsQuery = `SELECT COUNT(*) AS comments FROM "videoComment" WHERE "videoId" = :videoId`
138 const commentsPromise = LocalVideoViewerModel.sequelize.query<any>(commentsQuery, options)
139
140 const countriesQuery = `SELECT country, COUNT(country) as viewers ` + 137 const countriesQuery = `SELECT country, COUNT(country) as viewers ` +
141 `FROM "localVideoViewer" ` + 138 `FROM "localVideoViewer" ` +
142 `WHERE "videoId" = :videoId AND country IS NOT NULL ` + 139 `WHERE "videoId" = :videoId AND country IS NOT NULL ` +
@@ -144,10 +141,9 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
144 `ORDER BY viewers DESC` 141 `ORDER BY viewers DESC`
145 const countriesPromise = LocalVideoViewerModel.sequelize.query<any>(countriesQuery, options) 142 const countriesPromise = LocalVideoViewerModel.sequelize.query<any>(countriesQuery, options)
146 143
147 const [ rowsWatchTime, rowsWatchPeak, rowsComment, rowsCountries ] = await Promise.all([ 144 const [ rowsWatchTime, rowsWatchPeak, rowsCountries ] = await Promise.all([
148 watchTimePromise, 145 watchTimePromise,
149 watchPeakPromise, 146 watchPeakPromise,
150 commentsPromise,
151 countriesPromise 147 countriesPromise
152 ]) 148 ])
153 149
@@ -166,14 +162,6 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
166 ? rowsWatchPeak[0].dateBreakpoint || null 162 ? rowsWatchPeak[0].dateBreakpoint || null
167 : null, 163 : null,
168 164
169 views: video.views,
170 likes: video.likes,
171 dislikes: video.dislikes,
172
173 comments: rowsComment.length !== 0
174 ? parseInt(rowsComment[0].comments) || 0
175 : 0,
176
177 countries: rowsCountries.map(r => ({ 165 countries: rowsCountries.map(r => ({
178 isoCode: r.country, 166 isoCode: r.country,
179 viewers: r.viewers 167 viewers: r.viewers