diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-11 10:59:27 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-11 11:15:44 +0200 |
commit | 17bb45388ec319d288a1b8387c6c199fe2f6b64f (patch) | |
tree | 96a6b331ce1766eced50f78ab3ce0ed9197d8833 /server/models/video/sql/shared/abstract-videos-model-query-builder.ts | |
parent | ca4b4b2e5590c1b37cff1fe1be7f797b93351229 (diff) | |
download | PeerTube-17bb45388ec319d288a1b8387c6c199fe2f6b64f.tar.gz PeerTube-17bb45388ec319d288a1b8387c6c199fe2f6b64f.tar.zst PeerTube-17bb45388ec319d288a1b8387c6c199fe2f6b64f.zip |
Optimize rows parsing
Diffstat (limited to 'server/models/video/sql/shared/abstract-videos-model-query-builder.ts')
-rw-r--r-- | server/models/video/sql/shared/abstract-videos-model-query-builder.ts | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts index 8ed207eea..8eff59db0 100644 --- a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts +++ b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import validator from 'validator' | 1 | import validator from 'validator' |
2 | import { AbstractVideosQueryBuilder } from './abstract-videos-query-builder' | 2 | import { AbstractVideosQueryBuilder } from './abstract-videos-query-builder' |
3 | import { VideoAttributes } from './video-attributes' | 3 | import { VideoTables } from './video-tables' |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * | 6 | * |
@@ -13,12 +13,12 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
13 | protected joins: string[] = [] | 13 | protected joins: string[] = [] |
14 | protected where: string | 14 | protected where: string |
15 | 15 | ||
16 | protected videoAttributes: VideoAttributes | 16 | protected tables: VideoTables |
17 | 17 | ||
18 | constructor (protected readonly mode: 'list' | 'get') { | 18 | constructor (protected readonly mode: 'list' | 'get') { |
19 | super() | 19 | super() |
20 | 20 | ||
21 | this.videoAttributes = new VideoAttributes(this.mode) | 21 | this.tables = new VideoTables(this.mode) |
22 | } | 22 | } |
23 | 23 | ||
24 | protected buildSelect () { | 24 | protected buildSelect () { |
@@ -44,7 +44,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
44 | this.attributes = { | 44 | this.attributes = { |
45 | ...this.attributes, | 45 | ...this.attributes, |
46 | 46 | ||
47 | ...this.buildAttributesObject('VideoChannel', this.videoAttributes.getChannelAttributes()), | 47 | ...this.buildAttributesObject('VideoChannel', this.tables.getChannelAttributes()), |
48 | ...this.buildActorInclude('VideoChannel->Actor'), | 48 | ...this.buildActorInclude('VideoChannel->Actor'), |
49 | ...this.buildAvatarInclude('VideoChannel->Actor->Avatar'), | 49 | ...this.buildAvatarInclude('VideoChannel->Actor->Avatar'), |
50 | ...this.buildServerInclude('VideoChannel->Actor->Server') | 50 | ...this.buildServerInclude('VideoChannel->Actor->Server') |
@@ -66,7 +66,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
66 | this.attributes = { | 66 | this.attributes = { |
67 | ...this.attributes, | 67 | ...this.attributes, |
68 | 68 | ||
69 | ...this.buildAttributesObject('VideoChannel->Account', this.videoAttributes.getAccountAttributes()), | 69 | ...this.buildAttributesObject('VideoChannel->Account', this.tables.getAccountAttributes()), |
70 | ...this.buildActorInclude('VideoChannel->Account->Actor'), | 70 | ...this.buildActorInclude('VideoChannel->Account->Actor'), |
71 | ...this.buildAvatarInclude('VideoChannel->Account->Actor->Avatar'), | 71 | ...this.buildAvatarInclude('VideoChannel->Account->Actor->Avatar'), |
72 | ...this.buildServerInclude('VideoChannel->Account->Actor->Server') | 72 | ...this.buildServerInclude('VideoChannel->Account->Actor->Server') |
@@ -79,7 +79,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
79 | this.attributes = { | 79 | this.attributes = { |
80 | ...this.attributes, | 80 | ...this.attributes, |
81 | 81 | ||
82 | ...this.buildAttributesObject('Thumbnails', this.videoAttributes.getThumbnailAttributes()) | 82 | ...this.buildAttributesObject('Thumbnails', this.tables.getThumbnailAttributes()) |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
@@ -90,7 +90,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
90 | this.attributes = { | 90 | this.attributes = { |
91 | ...this.attributes, | 91 | ...this.attributes, |
92 | 92 | ||
93 | ...this.buildAttributesObject('VideoFiles', this.videoAttributes.getFileAttributes()) | 93 | ...this.buildAttributesObject('VideoFiles', this.tables.getFileAttributes()) |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
@@ -107,8 +107,8 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
107 | this.attributes = { | 107 | this.attributes = { |
108 | ...this.attributes, | 108 | ...this.attributes, |
109 | 109 | ||
110 | ...this.buildAttributesObject('VideoStreamingPlaylists', this.videoAttributes.getStreamingPlaylistAttributes()), | 110 | ...this.buildAttributesObject('VideoStreamingPlaylists', this.tables.getStreamingPlaylistAttributes()), |
111 | ...this.buildAttributesObject('VideoStreamingPlaylists->VideoFiles', this.videoAttributes.getFileAttributes()) | 111 | ...this.buildAttributesObject('VideoStreamingPlaylists->VideoFiles', this.tables.getFileAttributes()) |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
@@ -123,7 +123,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
123 | this.attributes = { | 123 | this.attributes = { |
124 | ...this.attributes, | 124 | ...this.attributes, |
125 | 125 | ||
126 | ...this.buildAttributesObject('userVideoHistory', this.videoAttributes.getUserHistoryAttributes()) | 126 | ...this.buildAttributesObject('userVideoHistory', this.tables.getUserHistoryAttributes()) |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
@@ -138,7 +138,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
138 | this.attributes = { | 138 | this.attributes = { |
139 | ...this.attributes, | 139 | ...this.attributes, |
140 | 140 | ||
141 | ...this.buildAttributesObject('VideoPlaylistElement', this.videoAttributes.getPlaylistAttributes()) | 141 | ...this.buildAttributesObject('VideoPlaylistElement', this.tables.getPlaylistAttributes()) |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
@@ -153,8 +153,8 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
153 | this.attributes = { | 153 | this.attributes = { |
154 | ...this.attributes, | 154 | ...this.attributes, |
155 | 155 | ||
156 | ...this.buildAttributesObject('Tags', this.videoAttributes.getTagAttributes()), | 156 | ...this.buildAttributesObject('Tags', this.tables.getTagAttributes()), |
157 | ...this.buildAttributesObject('Tags->VideoTagModel', this.videoAttributes.getVideoTagAttributes()) | 157 | ...this.buildAttributesObject('Tags->VideoTagModel', this.tables.getVideoTagAttributes()) |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
@@ -166,7 +166,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
166 | this.attributes = { | 166 | this.attributes = { |
167 | ...this.attributes, | 167 | ...this.attributes, |
168 | 168 | ||
169 | ...this.buildAttributesObject('VideoBlacklist', this.videoAttributes.getBlacklistedAttributes()) | 169 | ...this.buildAttributesObject('VideoBlacklist', this.tables.getBlacklistedAttributes()) |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -178,7 +178,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
178 | this.attributes = { | 178 | this.attributes = { |
179 | ...this.attributes, | 179 | ...this.attributes, |
180 | 180 | ||
181 | ...this.buildAttributesObject('ScheduleVideoUpdate', this.videoAttributes.getScheduleUpdateAttributes()) | 181 | ...this.buildAttributesObject('ScheduleVideoUpdate', this.tables.getScheduleUpdateAttributes()) |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
@@ -190,7 +190,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
190 | this.attributes = { | 190 | this.attributes = { |
191 | ...this.attributes, | 191 | ...this.attributes, |
192 | 192 | ||
193 | ...this.buildAttributesObject('VideoLive', this.videoAttributes.getLiveAttributes()) | 193 | ...this.buildAttributesObject('VideoLive', this.tables.getLiveAttributes()) |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
@@ -205,8 +205,8 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
205 | this.attributes = { | 205 | this.attributes = { |
206 | ...this.attributes, | 206 | ...this.attributes, |
207 | 207 | ||
208 | ...this.buildAttributesObject('Trackers', this.videoAttributes.getTrackerAttributes()), | 208 | ...this.buildAttributesObject('Trackers', this.tables.getTrackerAttributes()), |
209 | ...this.buildAttributesObject('Trackers->VideoTrackerModel', this.videoAttributes.getVideoTrackerAttributes()) | 209 | ...this.buildAttributesObject('Trackers->VideoTrackerModel', this.tables.getVideoTrackerAttributes()) |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
@@ -219,7 +219,7 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
219 | this.attributes = { | 219 | this.attributes = { |
220 | ...this.attributes, | 220 | ...this.attributes, |
221 | 221 | ||
222 | ...this.buildAttributesObject('VideoFiles->RedundancyVideos', this.videoAttributes.getRedundancyAttributes()) | 222 | ...this.buildAttributesObject('VideoFiles->RedundancyVideos', this.tables.getRedundancyAttributes()) |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
@@ -232,20 +232,20 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
232 | this.attributes = { | 232 | this.attributes = { |
233 | ...this.attributes, | 233 | ...this.attributes, |
234 | 234 | ||
235 | ...this.buildAttributesObject('VideoStreamingPlaylists->RedundancyVideos', this.videoAttributes.getRedundancyAttributes()) | 235 | ...this.buildAttributesObject('VideoStreamingPlaylists->RedundancyVideos', this.tables.getRedundancyAttributes()) |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | protected buildActorInclude (prefixKey: string) { | 239 | protected buildActorInclude (prefixKey: string) { |
240 | return this.buildAttributesObject(prefixKey, this.videoAttributes.getActorAttributes()) | 240 | return this.buildAttributesObject(prefixKey, this.tables.getActorAttributes()) |
241 | } | 241 | } |
242 | 242 | ||
243 | protected buildAvatarInclude (prefixKey: string) { | 243 | protected buildAvatarInclude (prefixKey: string) { |
244 | return this.buildAttributesObject(prefixKey, this.videoAttributes.getAvatarAttributes()) | 244 | return this.buildAttributesObject(prefixKey, this.tables.getAvatarAttributes()) |
245 | } | 245 | } |
246 | 246 | ||
247 | protected buildServerInclude (prefixKey: string) { | 247 | protected buildServerInclude (prefixKey: string) { |
248 | return this.buildAttributesObject(prefixKey, this.videoAttributes.getServerAttributes()) | 248 | return this.buildAttributesObject(prefixKey, this.tables.getServerAttributes()) |
249 | } | 249 | } |
250 | 250 | ||
251 | protected buildAttributesObject (prefixKey: string, attributeKeys: string[]) { | 251 | protected buildAttributesObject (prefixKey: string, attributeKeys: string[]) { |