in marketing-analytics/activation/gmp-googleads-connector/src/tentacles.js [391:439]
async fileJobManager(request, response) {
const parameters = request.body;
this.logger.info('Http get:', parameters);
const { fileId, file } = parameters;
if (fileId) {
const tentaclesFile = await this.tentaclesFileDao.load(fileId);
if (!tentaclesFile) {
response.send({ error: `Can not find TentacleFile id: ${fileId}.` });
}
if (tentaclesFile.status === TentaclesFileStatus.STARTED) {
await this.updateStartedFileStatus(fileId, tentaclesFile.numberOfTasks);
} else if (tentaclesFile.status === TentaclesFileStatus.QUEUING) {
await this.updateQueuingFileStatus(fileId,
tentaclesFile.startQueuingTime);
}
const updatedFile = await this.tentaclesFileDao.load(fileId);
response.send({
fileId,
status: updatedFile.status,
error: updatedFile.error,
numberOfFailed: updatedFile.numberOfFailed,
numberOfLines: updatedFile.numberOfLines,
numberOfTasks: updatedFile.updatedFile,
hasError: updatedFile.hasError,
});
} else if (file) {
const regex = /^gs:\/\/([^\/]*)\/(.*)$/g;
const matches = regex.exec(file);
const bucket = matches[1];
const fileName = matches[2];
this.logger.info(`Http get ${bucket}, ${fileName}`);
try {
const fileObj =
await this.options.getStorage(bucket, fileName).getFile().get();
const { attributes, config } = parameters;
const fileId = await moveAndProcessFile(
this.getLoadFileAndNudgeFn({ attributes, config }), fileObj[1], 'Http');
response.send({ fileId });
} catch (error) {
this.logger.error('Http failed', error);
response.send({ error: error.message });
}
} else {
this.logger.error('Unknow data', parameters);
response.send({
error: `Missing data in request, ${JSON.stringify(parameters)}`,
});
}
}