X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fserver-commands%2Fmiscs%2Fsql-command.ts;h=823fc9e388d6a7dcc0b3611da039c4d79824eb66;hb=9972ace3a3bc65865fb3aaaa865a400386e49252;hp=b0d9ce56d734df4f171726c6a2c9f849c06577b9;hpb=2f061e065ab43cc0b73595b619639a92952aeeba;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/server-commands/miscs/sql-command.ts b/shared/server-commands/miscs/sql-command.ts index b0d9ce56d..823fc9e38 100644 --- a/shared/server-commands/miscs/sql-command.ts +++ b/shared/server-commands/miscs/sql-command.ts @@ -1,4 +1,5 @@ import { QueryTypes, Sequelize } from 'sequelize' +import { forceNumber } from '@shared/core-utils' import { AbstractCommand } from '../shared' export class SQLCommand extends AbstractCommand { @@ -63,7 +64,7 @@ export class SQLCommand extends AbstractCommand { if (!total) return 0 - return parseInt(total + '', 10) + return forceNumber(total) } getActorImage (filename: string) { @@ -85,6 +86,8 @@ export class SQLCommand extends AbstractCommand { return seq.query(query, options) } + // --------------------------------------------------------------------------- + setPluginField (pluginName: string, field: string, value: string) { const seq = this.getSequelize() @@ -101,6 +104,17 @@ export class SQLCommand extends AbstractCommand { return this.setPluginField(pluginName, 'latestVersion', newVersion) } + // --------------------------------------------------------------------------- + + async getPlaylistInfohash (playlistId: number) { + const result = await this.selectQuery('SELECT "p2pMediaLoaderInfohashes" FROM "videoStreamingPlaylist" WHERE id = ' + playlistId) + if (!result || result.length === 0) return [] + + return result[0].p2pMediaLoaderInfohashes + } + + // --------------------------------------------------------------------------- + setActorFollowScores (newScore: number) { const seq = this.getSequelize() @@ -130,7 +144,7 @@ export class SQLCommand extends AbstractCommand { const dbname = 'peertube_test' + this.server.internalServerNumber const username = 'peertube' const password = 'peertube' - const host = 'localhost' + const host = '127.0.0.1' const port = 5432 this.sequelize = new Sequelize(dbname, username, password, {