|
|
@@ -82,7 +82,9 @@ export class SyncVideomediaService {
|
|
|
|
|
|
const normalized = list.map((item) => this.normalizeItem(item));
|
|
|
|
|
|
- console.log(`[sync-videomedia] Ready to import ${normalized.length} records`);
|
|
|
+ console.log(
|
|
|
+ `[sync-videomedia] Ready to import ${normalized.length} records`,
|
|
|
+ );
|
|
|
console.log('[sync-videomedia] First record sample:', normalized[0]);
|
|
|
|
|
|
// Batch processing - try to create each record individually and catch duplicate errors
|
|
|
@@ -90,7 +92,7 @@ export class SyncVideomediaService {
|
|
|
let created = 0;
|
|
|
let updated = 0;
|
|
|
let skipped = 0;
|
|
|
- let errors: any[] = [];
|
|
|
+ const errors: any[] = [];
|
|
|
|
|
|
for (let i = 0; i < normalized.length; i += BATCH_SIZE) {
|
|
|
const batch = normalized.slice(i, i + BATCH_SIZE);
|
|
|
@@ -130,7 +132,10 @@ export class SyncVideomediaService {
|
|
|
errors.push({ id: record.id, error: updateError.message });
|
|
|
}
|
|
|
} else {
|
|
|
- console.error(`[sync-videomedia] Skipped ${record.id}:`, error.message);
|
|
|
+ console.error(
|
|
|
+ `[sync-videomedia] Skipped ${record.id}:`,
|
|
|
+ error.message,
|
|
|
+ );
|
|
|
skipped++;
|
|
|
errors.push({ id: record.id, error: error.message });
|
|
|
}
|
|
|
@@ -173,7 +178,9 @@ export class SyncVideomediaService {
|
|
|
return data.list as RawVideoMedia[];
|
|
|
}
|
|
|
|
|
|
- throw new BadRequestException('Invalid JSON structure: expected array, data.list, or list');
|
|
|
+ throw new BadRequestException(
|
|
|
+ 'Invalid JSON structure: expected array, data.list, or list',
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -186,15 +193,23 @@ export class SyncVideomediaService {
|
|
|
throw new BadRequestException('Each item must have an id');
|
|
|
}
|
|
|
if (!item.addedTime || !item.createdAt || !item.updatedAt) {
|
|
|
- throw new BadRequestException(`Item ${item.id} is missing required datetime fields`);
|
|
|
+ throw new BadRequestException(
|
|
|
+ `Item ${item.id} is missing required datetime fields`,
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
const addedTime = new Date(item.addedTime);
|
|
|
const createdAt = new Date(item.createdAt);
|
|
|
const updatedAt = new Date(item.updatedAt);
|
|
|
|
|
|
- if (isNaN(addedTime.getTime()) || isNaN(createdAt.getTime()) || isNaN(updatedAt.getTime())) {
|
|
|
- throw new BadRequestException(`Item ${item.id} has invalid datetime format`);
|
|
|
+ if (
|
|
|
+ isNaN(addedTime.getTime()) ||
|
|
|
+ isNaN(createdAt.getTime()) ||
|
|
|
+ isNaN(updatedAt.getTime())
|
|
|
+ ) {
|
|
|
+ throw new BadRequestException(
|
|
|
+ `Item ${item.id} has invalid datetime format`,
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
return {
|