aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/sql/shared/video-tables.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-11 10:59:27 +0200
committerChocobozzz <me@florianbigard.com>2021-06-11 11:15:44 +0200
commit17bb45388ec319d288a1b8387c6c199fe2f6b64f (patch)
tree96a6b331ce1766eced50f78ab3ce0ed9197d8833 /server/models/video/sql/shared/video-tables.ts
parentca4b4b2e5590c1b37cff1fe1be7f797b93351229 (diff)
downloadPeerTube-17bb45388ec319d288a1b8387c6c199fe2f6b64f.tar.gz
PeerTube-17bb45388ec319d288a1b8387c6c199fe2f6b64f.tar.zst
PeerTube-17bb45388ec319d288a1b8387c6c199fe2f6b64f.zip
Optimize rows parsing
Diffstat (limited to 'server/models/video/sql/shared/video-tables.ts')
-rw-r--r--server/models/video/sql/shared/video-tables.ts254
1 files changed, 254 insertions, 0 deletions
diff --git a/server/models/video/sql/shared/video-tables.ts b/server/models/video/sql/shared/video-tables.ts
new file mode 100644
index 000000000..fddf1210c
--- /dev/null
+++ b/server/models/video/sql/shared/video-tables.ts
@@ -0,0 +1,254 @@
1
2/**
3 *
4 * Class to build video attributes/join names we want to fetch from the database
5 *
6 */
7export class VideoTables {
8
9 constructor (readonly mode: 'get' | 'list') {
10
11 }
12
13 getChannelAttributes () {
14 let attributeKeys = [
15 'id',
16 'name',
17 'description',
18 'actorId'
19 ]
20
21 if (this.mode === 'get') {
22 attributeKeys = attributeKeys.concat([
23 'support',
24 'createdAt',
25 'updatedAt'
26 ])
27 }
28
29 return attributeKeys
30 }
31
32 getAccountAttributes () {
33 let attributeKeys = [ 'id', 'name', 'actorId' ]
34
35 if (this.mode === 'get') {
36 attributeKeys = attributeKeys.concat([
37 'description',
38 'createdAt',
39 'updatedAt'
40 ])
41 }
42
43 return attributeKeys
44 }
45
46 getThumbnailAttributes () {
47 let attributeKeys = [ 'id', 'type', 'filename' ]
48
49 if (this.mode === 'get') {
50 attributeKeys = attributeKeys.concat([
51 'height',
52 'width',
53 'fileUrl',
54 'automaticallyGenerated',
55 'videoId',
56 'videoPlaylistId',
57 'createdAt',
58 'updatedAt'
59 ])
60 }
61
62 return attributeKeys
63 }
64
65 getFileAttributes () {
66 return [
67 'id',
68 'createdAt',
69 'updatedAt',
70 'resolution',
71 'size',
72 'extname',
73 'filename',
74 'fileUrl',
75 'torrentFilename',
76 'torrentUrl',
77 'infoHash',
78 'fps',
79 'metadataUrl',
80 'videoStreamingPlaylistId',
81 'videoId'
82 ]
83 }
84
85 getStreamingPlaylistAttributes () {
86 let playlistKeys = [ 'id', 'playlistUrl', 'type' ]
87
88 if (this.mode === 'get') {
89 playlistKeys = playlistKeys.concat([
90 'p2pMediaLoaderInfohashes',
91 'p2pMediaLoaderPeerVersion',
92 'segmentsSha256Url',
93 'videoId',
94 'createdAt',
95 'updatedAt'
96 ])
97 }
98
99 return playlistKeys
100 }
101
102 getUserHistoryAttributes () {
103 return [ 'id', 'currentTime' ]
104 }
105
106 getPlaylistAttributes () {
107 return [
108 'createdAt',
109 'updatedAt',
110 'url',
111 'position',
112 'startTimestamp',
113 'stopTimestamp',
114 'videoPlaylistId'
115 ]
116 }
117
118 getTagAttributes () {
119 return [ 'id', 'name' ]
120 }
121
122 getVideoTagAttributes () {
123 return [ 'videoId', 'tagId', 'createdAt', 'updatedAt' ]
124 }
125
126 getBlacklistedAttributes () {
127 return [ 'id', 'reason', 'unfederated' ]
128 }
129
130 getScheduleUpdateAttributes () {
131 return [
132 'id',
133 'updateAt',
134 'privacy',
135 'videoId',
136 'createdAt',
137 'updatedAt'
138 ]
139 }
140
141 getLiveAttributes () {
142 return [
143 'id',
144 'streamKey',
145 'saveReplay',
146 'permanentLive',
147 'videoId',
148 'createdAt',
149 'updatedAt'
150 ]
151 }
152
153 getTrackerAttributes () {
154 return [ 'id', 'url' ]
155 }
156
157 getVideoTrackerAttributes () {
158 return [
159 'videoId',
160 'trackerId',
161 'createdAt',
162 'updatedAt'
163 ]
164 }
165
166 getRedundancyAttributes () {
167 return [ 'id', 'fileUrl' ]
168 }
169
170 getActorAttributes () {
171 let attributeKeys = [
172 'id',
173 'preferredUsername',
174 'url',
175 'serverId',
176 'avatarId'
177 ]
178
179 if (this.mode === 'get') {
180 attributeKeys = attributeKeys.concat([
181 'type',
182 'followersCount',
183 'followingCount',
184 'inboxUrl',
185 'outboxUrl',
186 'sharedInboxUrl',
187 'followersUrl',
188 'followingUrl',
189 'remoteCreatedAt',
190 'createdAt',
191 'updatedAt'
192 ])
193 }
194
195 return attributeKeys
196 }
197
198 getAvatarAttributes () {
199 let attributeKeys = [
200 'id',
201 'filename',
202 'type',
203 'fileUrl',
204 'onDisk',
205 'createdAt',
206 'updatedAt'
207 ]
208
209 if (this.mode === 'get') {
210 attributeKeys = attributeKeys.concat([
211 'height',
212 'width',
213 'type'
214 ])
215 }
216
217 return attributeKeys
218 }
219
220 getServerAttributes () {
221 return [ 'id', 'host' ]
222 }
223
224 getVideoAttributes () {
225 return [
226 'id',
227 'uuid',
228 'name',
229 'category',
230 'licence',
231 'language',
232 'privacy',
233 'nsfw',
234 'description',
235 'support',
236 'duration',
237 'views',
238 'likes',
239 'dislikes',
240 'remote',
241 'isLive',
242 'url',
243 'commentsEnabled',
244 'downloadEnabled',
245 'waitTranscoding',
246 'state',
247 'publishedAt',
248 'originallyPublishedAt',
249 'channelId',
250 'createdAt',
251 'updatedAt'
252 ]
253 }
254}