diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/miscs/sql.ts | 35 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/videos/video-playlists.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 4 |
4 files changed, 23 insertions, 22 deletions
diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 3cfae5c23..34477cb78 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { QueryTypes, Sequelize } from 'sequelize' | 1 | import { QueryTypes, Sequelize } from 'sequelize' |
2 | import { ServerInfo } from '../server/servers' | ||
2 | 3 | ||
3 | let sequelizes: { [ id: number ]: Sequelize } = {} | 4 | let sequelizes: { [ id: number ]: Sequelize } = {} |
4 | 5 | ||
5 | function getSequelize (serverNumber: number) { | 6 | function getSequelize (internalServerNumber: number) { |
6 | if (sequelizes[serverNumber]) return sequelizes[serverNumber] | 7 | if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber] |
7 | 8 | ||
8 | const dbname = 'peertube_test' + serverNumber | 9 | const dbname = 'peertube_test' + internalServerNumber |
9 | const username = 'peertube' | 10 | const username = 'peertube' |
10 | const password = 'peertube' | 11 | const password = 'peertube' |
11 | const host = 'localhost' | 12 | const host = 'localhost' |
@@ -18,37 +19,37 @@ function getSequelize (serverNumber: number) { | |||
18 | logging: false | 19 | logging: false |
19 | }) | 20 | }) |
20 | 21 | ||
21 | sequelizes[serverNumber] = seq | 22 | sequelizes[internalServerNumber] = seq |
22 | 23 | ||
23 | return seq | 24 | return seq |
24 | } | 25 | } |
25 | 26 | ||
26 | function setActorField (serverNumber: number, to: string, field: string, value: string) { | 27 | function setActorField (internalServerNumber: number, to: string, field: string, value: string) { |
27 | const seq = getSequelize(serverNumber) | 28 | const seq = getSequelize(internalServerNumber) |
28 | 29 | ||
29 | const options = { type: QueryTypes.UPDATE } | 30 | const options = { type: QueryTypes.UPDATE } |
30 | 31 | ||
31 | return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options) | 32 | return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options) |
32 | } | 33 | } |
33 | 34 | ||
34 | function setVideoField (serverNumber: number, uuid: string, field: string, value: string) { | 35 | function setVideoField (internalServerNumber: number, uuid: string, field: string, value: string) { |
35 | const seq = getSequelize(serverNumber) | 36 | const seq = getSequelize(internalServerNumber) |
36 | 37 | ||
37 | const options = { type: QueryTypes.UPDATE } | 38 | const options = { type: QueryTypes.UPDATE } |
38 | 39 | ||
39 | return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) | 40 | return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) |
40 | } | 41 | } |
41 | 42 | ||
42 | function setPlaylistField (serverNumber: number, uuid: string, field: string, value: string) { | 43 | function setPlaylistField (internalServerNumber: number, uuid: string, field: string, value: string) { |
43 | const seq = getSequelize(serverNumber) | 44 | const seq = getSequelize(internalServerNumber) |
44 | 45 | ||
45 | const options = { type: QueryTypes.UPDATE } | 46 | const options = { type: QueryTypes.UPDATE } |
46 | 47 | ||
47 | return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) | 48 | return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) |
48 | } | 49 | } |
49 | 50 | ||
50 | async function countVideoViewsOf (serverNumber: number, uuid: string) { | 51 | async function countVideoViewsOf (internalServerNumber: number, uuid: string) { |
51 | const seq = getSequelize(serverNumber) | 52 | const seq = getSequelize(internalServerNumber) |
52 | 53 | ||
53 | // tslint:disable | 54 | // tslint:disable |
54 | const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` | 55 | const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` |
@@ -62,11 +63,11 @@ async function countVideoViewsOf (serverNumber: number, uuid: string) { | |||
62 | return parseInt(total + '', 10) | 63 | return parseInt(total + '', 10) |
63 | } | 64 | } |
64 | 65 | ||
65 | async function closeAllSequelize (servers: any[]) { | 66 | async function closeAllSequelize (servers: ServerInfo[]) { |
66 | for (let i = 1; i <= servers.length; i++) { | 67 | for (const server of servers) { |
67 | if (sequelizes[ i ]) { | 68 | if (sequelizes[ server.internalServerNumber ]) { |
68 | await sequelizes[ i ].close() | 69 | await sequelizes[ server.internalServerNumber ].close() |
69 | delete sequelizes[ i ] | 70 | delete sequelizes[ server.internalServerNumber ] |
70 | } | 71 | } |
71 | } | 72 | } |
72 | } | 73 | } |
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 3992735e1..4c7d6862a 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -246,7 +246,7 @@ async function checkTmpIsEmpty (server: ServerInfo) { | |||
246 | } | 246 | } |
247 | 247 | ||
248 | async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { | 248 | async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { |
249 | const testDirectory = 'test' + server.serverNumber | 249 | const testDirectory = 'test' + server.internalServerNumber |
250 | 250 | ||
251 | const directoryPath = join(root(), testDirectory, directory) | 251 | const directoryPath = join(root(), testDirectory, directory) |
252 | 252 | ||
diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.ts index 4d110a131..fd62bef19 100644 --- a/shared/extra-utils/videos/video-playlists.ts +++ b/shared/extra-utils/videos/video-playlists.ts | |||
@@ -252,10 +252,10 @@ function reorderVideosPlaylist (options: { | |||
252 | 252 | ||
253 | async function checkPlaylistFilesWereRemoved ( | 253 | async function checkPlaylistFilesWereRemoved ( |
254 | playlistUUID: string, | 254 | playlistUUID: string, |
255 | serverNumber: number, | 255 | internalServerNumber: number, |
256 | directories = [ 'thumbnails' ] | 256 | directories = [ 'thumbnails' ] |
257 | ) { | 257 | ) { |
258 | const testDirectory = 'test' + serverNumber | 258 | const testDirectory = 'test' + internalServerNumber |
259 | 259 | ||
260 | for (const directory of directories) { | 260 | for (const directory of directories) { |
261 | const directoryPath = join(root(), testDirectory, directory) | 261 | const directoryPath = join(root(), testDirectory, directory) |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index b5a07b792..b64de2470 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -568,8 +568,8 @@ async function completeVideoCheck ( | |||
568 | expect(file).not.to.be.undefined | 568 | expect(file).not.to.be.undefined |
569 | 569 | ||
570 | let extension = extname(attributes.fixture) | 570 | let extension = extname(attributes.fixture) |
571 | // Transcoding enabled on server 2, extension will always be .mp4 | 571 | // Transcoding enabled: extension will always be .mp4 |
572 | if (attributes.account.host === 'localhost:9002') extension = '.mp4' | 572 | if (attributes.files.length > 1) extension = '.mp4' |
573 | 573 | ||
574 | const magnetUri = file.magnetUri | 574 | const magnetUri = file.magnetUri |
575 | expect(file.magnetUri).to.have.lengthOf.above(2) | 575 | expect(file.magnetUri).to.have.lengthOf.above(2) |