]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/sql/shared/video-tables.ts
Deprecate filter video query
[github/Chocobozzz/PeerTube.git] / server / models / video / sql / shared / video-tables.ts
CommitLineData
1d43c3a6
C
1
2/**
3 *
17bb4538 4 * Class to build video attributes/join names we want to fetch from the database
1d43c3a6
C
5 *
6 */
17bb4538 7export class VideoTables {
d9bf974f
C
8
9 constructor (readonly mode: 'get' | 'list') {
10
11 }
12
71d4af1e
C
13 getChannelAttributesForUser () {
14 return [ 'id', 'accountId' ]
15 }
16
d9bf974f
C
17 getChannelAttributes () {
18 let attributeKeys = [
19 'id',
20 'name',
21 'description',
22 'actorId'
23 ]
24
25 if (this.mode === 'get') {
26 attributeKeys = attributeKeys.concat([
27 'support',
28 'createdAt',
29 'updatedAt'
30 ])
31 }
32
33 return attributeKeys
34 }
35
71d4af1e
C
36 getUserAccountAttributes () {
37 return [ 'id', 'userId' ]
38 }
39
d9bf974f
C
40 getAccountAttributes () {
41 let attributeKeys = [ 'id', 'name', 'actorId' ]
42
43 if (this.mode === 'get') {
44 attributeKeys = attributeKeys.concat([
45 'description',
b8afe6f0 46 'userId',
d9bf974f
C
47 'createdAt',
48 'updatedAt'
49 ])
50 }
51
52 return attributeKeys
53 }
54
55 getThumbnailAttributes () {
56 let attributeKeys = [ 'id', 'type', 'filename' ]
57
58 if (this.mode === 'get') {
59 attributeKeys = attributeKeys.concat([
60 'height',
61 'width',
62 'fileUrl',
63 'automaticallyGenerated',
64 'videoId',
65 'videoPlaylistId',
66 'createdAt',
67 'updatedAt'
68 ])
69 }
70
71 return attributeKeys
72 }
73
74 getFileAttributes () {
75 return [
76 'id',
77 'createdAt',
78 'updatedAt',
79 'resolution',
80 'size',
81 'extname',
82 'filename',
83 'fileUrl',
84 'torrentFilename',
85 'torrentUrl',
86 'infoHash',
87 'fps',
88 'metadataUrl',
89 'videoStreamingPlaylistId',
0305db28
JB
90 'videoId',
91 'storage'
d9bf974f
C
92 ]
93 }
94
95 getStreamingPlaylistAttributes () {
764b1a14 96 let playlistKeys = [ 'id', 'playlistUrl', 'playlistFilename', 'type' ]
d9bf974f
C
97
98 if (this.mode === 'get') {
99 playlistKeys = playlistKeys.concat([
100 'p2pMediaLoaderInfohashes',
101 'p2pMediaLoaderPeerVersion',
764b1a14 102 'segmentsSha256Filename',
d9bf974f
C
103 'segmentsSha256Url',
104 'videoId',
105 'createdAt',
0305db28
JB
106 'updatedAt',
107 'storage'
d9bf974f
C
108 ])
109 }
110
111 return playlistKeys
112 }
113
114 getUserHistoryAttributes () {
115 return [ 'id', 'currentTime' ]
116 }
117
118 getPlaylistAttributes () {
119 return [
120 'createdAt',
121 'updatedAt',
122 'url',
123 'position',
124 'startTimestamp',
125 'stopTimestamp',
126 'videoPlaylistId'
127 ]
128 }
129
130 getTagAttributes () {
131 return [ 'id', 'name' ]
132 }
133
134 getVideoTagAttributes () {
135 return [ 'videoId', 'tagId', 'createdAt', 'updatedAt' ]
136 }
137
138 getBlacklistedAttributes () {
139 return [ 'id', 'reason', 'unfederated' ]
140 }
141
2760b454
C
142 getBlocklistAttributes () {
143 return [ 'id' ]
144 }
145
d9bf974f
C
146 getScheduleUpdateAttributes () {
147 return [
148 'id',
149 'updateAt',
150 'privacy',
151 'videoId',
152 'createdAt',
153 'updatedAt'
154 ]
155 }
156
157 getLiveAttributes () {
158 return [
159 'id',
160 'streamKey',
161 'saveReplay',
162 'permanentLive',
163 'videoId',
164 'createdAt',
165 'updatedAt'
166 ]
167 }
168
169 getTrackerAttributes () {
170 return [ 'id', 'url' ]
171 }
172
173 getVideoTrackerAttributes () {
174 return [
175 'videoId',
176 'trackerId',
177 'createdAt',
178 'updatedAt'
179 ]
180 }
181
182 getRedundancyAttributes () {
183 return [ 'id', 'fileUrl' ]
184 }
185
186 getActorAttributes () {
187 let attributeKeys = [
188 'id',
189 'preferredUsername',
190 'url',
191 'serverId',
192 'avatarId'
193 ]
194
195 if (this.mode === 'get') {
196 attributeKeys = attributeKeys.concat([
197 'type',
198 'followersCount',
199 'followingCount',
200 'inboxUrl',
201 'outboxUrl',
202 'sharedInboxUrl',
203 'followersUrl',
204 'followingUrl',
205 'remoteCreatedAt',
206 'createdAt',
207 'updatedAt'
208 ])
209 }
210
211 return attributeKeys
212 }
213
214 getAvatarAttributes () {
215 let attributeKeys = [
216 'id',
217 'filename',
17bb4538 218 'type',
d9bf974f
C
219 'fileUrl',
220 'onDisk',
221 'createdAt',
222 'updatedAt'
223 ]
224
225 if (this.mode === 'get') {
226 attributeKeys = attributeKeys.concat([
227 'height',
228 'width',
229 'type'
230 ])
231 }
232
233 return attributeKeys
234 }
235
236 getServerAttributes () {
237 return [ 'id', 'host' ]
238 }
239
240 getVideoAttributes () {
241 return [
242 'id',
243 'uuid',
244 'name',
245 'category',
246 'licence',
247 'language',
248 'privacy',
249 'nsfw',
250 'description',
251 'support',
252 'duration',
253 'views',
254 'likes',
255 'dislikes',
256 'remote',
257 'isLive',
258 'url',
259 'commentsEnabled',
260 'downloadEnabled',
261 'waitTranscoding',
262 'state',
263 'publishedAt',
264 'originallyPublishedAt',
265 'channelId',
266 'createdAt',
0305db28
JB
267 'updatedAt',
268 'moveJobsRunning'
d9bf974f
C
269 ]
270 }
271}