aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-31 16:30:11 +0200
committerChocobozzz <me@florianbigard.com>2019-05-31 16:44:46 +0200
commit7d14d4d2ca82cc43c93b45bb1f90af975cfbf67c (patch)
treed2d2c9806dd1bf551ad39102149f514bca4c52eb /server/models/video/video.ts
parent9977c128387f38dddd697b2e9a405dcea52407b7 (diff)
downloadPeerTube-7d14d4d2ca82cc43c93b45bb1f90af975cfbf67c.tar.gz
PeerTube-7d14d4d2ca82cc43c93b45bb1f90af975cfbf67c.tar.zst
PeerTube-7d14d4d2ca82cc43c93b45bb1f90af975cfbf67c.zip
Server: Bulk update videos support field
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index c0a7892a4..eccf0a4fa 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1515,6 +1515,29 @@ export class VideoModel extends Model<VideoModel> {
1515 .then(results => results.length === 1) 1515 .then(results => results.length === 1)
1516 } 1516 }
1517 1517
1518 static bulkUpdateSupportField (videoChannel: VideoChannelModel, t: Transaction) {
1519 const options = {
1520 where: {
1521 channelId: videoChannel.id
1522 },
1523 transaction: t
1524 }
1525
1526 return VideoModel.update({ support: videoChannel.support }, options)
1527 }
1528
1529 static getAllIdsFromChannel (videoChannel: VideoChannelModel) {
1530 const query = {
1531 attributes: [ 'id' ],
1532 where: {
1533 channelId: videoChannel.id
1534 }
1535 }
1536
1537 return VideoModel.findAll(query)
1538 .then(videos => videos.map(v => v.id))
1539 }
1540
1518 // threshold corresponds to how many video the field should have to be returned 1541 // threshold corresponds to how many video the field should have to be returned
1519 static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) { 1542 static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) {
1520 const serverActor = await getServerActor() 1543 const serverActor = await getServerActor()