Browse Source

Merge pull request #2965 from mnaamani/content-migration-exlucde-videos

content migration script: add excludeVideoIds argument
Lezek123 3 years ago
parent
commit
2b80f9aff2

+ 6 - 0
utils/migration-scripts/src/commands/sumer-giza/migrateContent.ts

@@ -57,6 +57,12 @@ export class MigrateContentCommand extends Command {
       description: 'Path to migration results directory',
       default: path.join(__dirname, '../../../results/sumer-giza'),
     }),
+    excludeVideoIds: flags.integer({
+      multiple: true,
+      description: 'Video ids to exclude from migration',
+      required: false,
+      default: [],
+    }),
   }
 
   async run(): Promise<void> {

+ 5 - 1
utils/migration-scripts/src/sumer-giza/ChannelsMigration.ts

@@ -13,6 +13,7 @@ export type ChannelsMigrationConfig = AssetsMigrationConfig & {
   channelIds: number[]
   channelBatchSize: number
   forceChannelOwnerMemberId: number | undefined
+  excludeVideoIds: number[]
 }
 
 export type ChannelsMigrationParams = AssetsMigrationParams & {
@@ -101,7 +102,10 @@ export class ChannelMigration extends AssetsMigration {
         }
       }
       const videoIdsToMigrate: number[] = channelsBatch.reduce<number[]>(
-        (res, { id, videos }) => (this.idsMap.has(parseInt(id)) ? res.concat(videos.map((v) => parseInt(v.id))) : res),
+        (res, { id, videos }) =>
+          this.idsMap.has(parseInt(id))
+            ? res.concat(videos.map((v) => parseInt(v.id)).filter((id) => !this.config.excludeVideoIds.includes(id)))
+            : res,
         []
       )
       this.videoIds = this.videoIds.concat(videoIdsToMigrate)

+ 1 - 0
utils/migration-scripts/src/sumer-giza/ContentMigration.ts

@@ -17,6 +17,7 @@ export type ContentMigrationConfig = {
   uploadSpBucketId: number
   uploadSpEndpoint: string
   migrationStatePath: string
+  excludeVideoIds: number[]
 }
 
 export class ContentMigration {