in packages/web-workers/src/controllers/scan-batch-request-feed-controller.ts [83:134]
private async writeRequestsToPermanentContainer(requests: ScanRunBatchRequest[], batchRequestId: string): Promise<void> {
const websiteScanResults: { scanId: string; websiteScanResult: WebsiteScanResult }[] = [];
const requestDocuments = requests.map<OnDemandPageScanResult>((request) => {
this.logger.logInfo('Created new scan result document in scan result storage container.', {
batchRequestId,
scanId: request.scanId,
});
let websiteScanRefs: WebsiteScanRef;
const websiteScanResult = this.createWebsiteScanResult(request);
if (websiteScanResult) {
websiteScanRefs = { id: websiteScanResult.id, scanGroupType: websiteScanResult.scanGroupType };
websiteScanResults.push({ scanId: request.scanId, websiteScanResult });
this.logger.logInfo('Referenced website scan result document to the new scan result document.', {
batchRequestId,
scanId: request.scanId,
websiteScanId: websiteScanResult.id,
scanGroupId: websiteScanResult.scanGroupId,
scanGroupType: websiteScanResult.scanGroupType,
});
}
return {
id: request.scanId,
url: request.url,
priority: request.priority,
itemType: ItemType.onDemandPageScanRunResult,
partitionKey: this.partitionKeyFactory.createPartitionKeyForDocument(ItemType.onDemandPageScanRunResult, request.scanId),
run: {
state: 'accepted',
timestamp: new Date().toJSON(),
},
batchRequestId: batchRequestId,
...(isEmpty(request.scanNotifyUrl)
? {}
: {
notification: {
state: 'pending',
scanNotifyUrl: request.scanNotifyUrl,
},
}),
websiteScanRefs: websiteScanRefs ? [websiteScanRefs] : undefined,
};
});
if (websiteScanResults.length > 0) {
await this.websiteScanResultProvider.mergeOrCreateBatch(websiteScanResults);
}
await this.onDemandPageScanRunResultProvider.writeScanRuns(requestDocuments);
this.logger.logInfo(`Completed adding scan requests to permanent scan result storage container.`);
}