diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-21 15:44:12 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-21 15:51:28 +0100 |
commit | c8000975d361fae166a6ebecac5005238e14d4c9 (patch) | |
tree | 67d7da38abc6c4d9ceb4d120088d499309f69e30 /shared/utils | |
parent | e359e88b08476041c3c52db02fb3ca4e5ee296ea (diff) | |
download | PeerTube-c8000975d361fae166a6ebecac5005238e14d4c9.tar.gz PeerTube-c8000975d361fae166a6ebecac5005238e14d4c9.tar.zst PeerTube-c8000975d361fae166a6ebecac5005238e14d4c9.zip |
Add NSFW info in about page
Diffstat (limited to 'shared/utils')
-rw-r--r-- | shared/utils/miscs/sql.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/shared/utils/miscs/sql.ts b/shared/utils/miscs/sql.ts index 027f78131..bb3f63837 100644 --- a/shared/utils/miscs/sql.ts +++ b/shared/utils/miscs/sql.ts | |||
@@ -1,19 +1,27 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | let sequelizes: { [ id: number ]: Sequelize.Sequelize } = {} | ||
4 | |||
3 | function getSequelize (serverNumber: number) { | 5 | function getSequelize (serverNumber: number) { |
6 | if (sequelizes[serverNumber]) return sequelizes[serverNumber] | ||
7 | |||
4 | const dbname = 'peertube_test' + serverNumber | 8 | const dbname = 'peertube_test' + serverNumber |
5 | const username = 'peertube' | 9 | const username = 'peertube' |
6 | const password = 'peertube' | 10 | const password = 'peertube' |
7 | const host = 'localhost' | 11 | const host = 'localhost' |
8 | const port = 5432 | 12 | const port = 5432 |
9 | 13 | ||
10 | return new Sequelize(dbname, username, password, { | 14 | const seq = new Sequelize(dbname, username, password, { |
11 | dialect: 'postgres', | 15 | dialect: 'postgres', |
12 | host, | 16 | host, |
13 | port, | 17 | port, |
14 | operatorsAliases: false, | 18 | operatorsAliases: false, |
15 | logging: false | 19 | logging: false |
16 | }) | 20 | }) |
21 | |||
22 | sequelizes[serverNumber] = seq | ||
23 | |||
24 | return seq | ||
17 | } | 25 | } |
18 | 26 | ||
19 | function setActorField (serverNumber: number, to: string, field: string, value: string) { | 27 | function setActorField (serverNumber: number, to: string, field: string, value: string) { |
@@ -32,7 +40,17 @@ function setVideoField (serverNumber: number, uuid: string, field: string, value | |||
32 | 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) |
33 | } | 41 | } |
34 | 42 | ||
43 | async function closeAllSequelize (servers: any[]) { | ||
44 | for (let i = 1; i <= servers.length; i++) { | ||
45 | if (sequelizes[ i ]) { | ||
46 | await sequelizes[ i ].close() | ||
47 | delete sequelizes[ i ] | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | |||
35 | export { | 52 | export { |
36 | setVideoField, | 53 | setVideoField, |
37 | setActorField | 54 | setActorField, |
55 | closeAllSequelize | ||
38 | } | 56 | } |