瀏覽代碼

feat(provider-video-sync): reintroduce ProviderVideoSyncModule and update page size limit

Dave 1 月之前
父節點
當前提交
d26bc8657e

+ 2 - 2
apps/box-mgnt-api/src/mgnt-backend/feature/feature.module.ts

@@ -4,13 +4,13 @@ import { Module } from '@nestjs/common';
 import { S3Module } from './s3/s3.module';
 import { SystemParamsModule } from './system-params/system-params.module';
 import { MgntHttpServiceModule } from './mgnt-http-service/mgnt-http-service.module';
-import { ProviderVideoSyncModule } from './provider-video-sync/provider-video-sync.module';
 import { AdsModule } from './ads/ads.module';
 import { CategoryModule } from './category/category.module';
 import { ChannelModule } from './channel/channel.module';
 import { TagModule } from './tag/tag.module';
 import { VideoMediaModule } from './video-media/video-media.module';
 import { HealthModule } from './health/health.module';
+import { ProviderVideoSyncModule } from './provider-video-sync/provider-video-sync.module';
 
 @Module({
   imports: [
@@ -22,9 +22,9 @@ import { HealthModule } from './health/health.module';
     ChannelModule,
     TagModule,
     MgntHttpServiceModule,
-    ProviderVideoSyncModule,
     VideoMediaModule,
     HealthModule,
+    ProviderVideoSyncModule,
   ],
 })
 export class FeatureModule {}

+ 0 - 1
apps/box-mgnt-api/src/mgnt-backend/feature/provider-video-sync/provider-video-sync.controller.ts

@@ -125,7 +125,6 @@ export class ProviderVideoSyncController {
     return this.service.syncFromProvider(options);
   }
 
-  @Get('history')
   @Post('history')
   @ApiOperation({
     summary: 'Get the latest provider video sync cursor info',

+ 1 - 1
apps/box-mgnt-api/src/mgnt-backend/feature/provider-video-sync/provider-video-sync.dto.ts

@@ -114,7 +114,7 @@ export class ProviderVideoSyncRunDto {
   @IsOptional()
   @IsInt()
   @Min(1)
-  @Max(500)
+  @Max(15000)
   pageSize?: number;
 
   @IsOptional()

+ 14 - 4
apps/box-mgnt-api/src/mgnt-backend/feature/provider-video-sync/provider-video-sync.service.ts

@@ -137,7 +137,7 @@ export class ProviderVideoSyncService {
 
   private lastSyncSummary: ProviderVideoSyncResult | null = null;
 
-  private readonly MAX_PAGE_SIZE = 500;
+  private readonly MAX_PAGE_SIZE = 15000;
   private readonly DEFAULT_PAGE_SIZE = 500;
   private readonly BATCH_SIZE = 100;
   private readonly BASELINE_PARTIAL_COUNT = 20000;
@@ -160,6 +160,10 @@ export class ProviderVideoSyncService {
       );
     }
 
+    this.logger.log(
+      `[syncFromProvider] options=${JSON.stringify(options)} apiUrl=${providerApiUrl}`,
+    );
+
     const defaultPageSize = providerConfig.itemsLimit ?? this.DEFAULT_PAGE_SIZE;
     const requestedPageSize = options.pageSize ?? defaultPageSize;
     const pageSize = this.clampInt(requestedPageSize, 1, this.MAX_PAGE_SIZE);
@@ -542,7 +546,7 @@ export class ProviderVideoSyncService {
     },
   ): Promise<RawProviderVideo[]> {
     try {
-      // Provider expects { data: "<json string>" } (based on code=400 Field=data expecting string)
+      // Provider expects { data: JSON.stringify(...) } (API enforces data field as string).
       const wrappedBody = {
         data: JSON.stringify({
           pageNum: body.pageNum,
@@ -551,8 +555,14 @@ export class ProviderVideoSyncService {
         }),
       };
 
+      const jsonBody = {
+        pageNum: body.pageNum,
+        pageSize: body.pageSize,
+        param: body.param,
+      };
+
       const response = await firstValueFrom(
-        this.httpService.post(apiUrl, wrappedBody, {
+        this.httpService.post(apiUrl, jsonBody, {
           headers: { 'Content-Type': 'application/json' },
           timeout: 30_000,
         }),
@@ -565,7 +575,7 @@ export class ProviderVideoSyncService {
       this.logger.log(
         `[fetchPage] Provider response preview: ${JSON.stringify(
           providerJson,
-        ).slice(0, 400)}...`,
+        ).slice(0, 800)}...`,
       );
 
       // Fail fast on provider errors (prevents "successful" runs with empty lists)

+ 2 - 0
apps/box-mgnt-api/src/mgnt-backend/mgnt-backend.module.ts

@@ -19,6 +19,7 @@ import { TagModule } from './feature/tag/tag.module';
 import { VideoMediaModule } from './feature/video-media/video-media.module';
 import { HealthModule } from './feature/health/health.module';
 import { CacheSyncModule } from '../cache-sync/cache-sync.module';
+import { ProviderVideoSyncModule } from './feature/provider-video-sync/provider-video-sync.module';
 
 @Module({
   imports: [
@@ -44,6 +45,7 @@ import { CacheSyncModule } from '../cache-sync/cache-sync.module';
           VideoMediaModule,
           HealthModule,
           CacheSyncModule,
+          ProviderVideoSyncModule,
         ],
       },
     ]),