X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fserver-commands%2Fmiscs%2Fsql-command.ts;h=823fc9e388d6a7dcc0b3611da039c4d79824eb66;hb=9972ace3a3bc65865fb3aaaa865a400386e49252;hp=09a99f8340066bdf2621d26b109ccc7a6b277ecf;hpb=c3edc5b074aa4bb1861ed0a94d3713808e87170f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/server-commands/miscs/sql-command.ts b/shared/server-commands/miscs/sql-command.ts index 09a99f834..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 { @@ -23,6 +24,11 @@ export class SQLCommand extends AbstractCommand { return parseInt(total, 10) } + async getInternalFileUrl (fileId: number) { + return this.selectQuery(`SELECT "fileUrl" FROM "videoFile" WHERE id = ${fileId}`) + .then(rows => rows[0].fileUrl as string) + } + setActorField (to: string, field: string, value: string) { const seq = this.getSequelize() @@ -58,7 +64,7 @@ export class SQLCommand extends AbstractCommand { if (!total) return 0 - return parseInt(total + '', 10) + return forceNumber(total) } getActorImage (filename: string) { @@ -80,6 +86,8 @@ export class SQLCommand extends AbstractCommand { return seq.query(query, options) } + // --------------------------------------------------------------------------- + setPluginField (pluginName: string, field: string, value: string) { const seq = this.getSequelize() @@ -96,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() @@ -125,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, {