]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/miscs/sql-command.ts
Merge branch 'release/5.0.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / server-commands / miscs / sql-command.ts
index b0d9ce56d734df4f171726c6a2c9f849c06577b9..823fc9e388d6a7dcc0b3611da039c4d79824eb66 100644 (file)
@@ -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, {