|
|
|
@ -40,7 +40,7 @@ export class DataGatheringService {
|
|
|
|
|
const isDataGatheringNeeded = await this.isDataGatheringNeeded();
|
|
|
|
|
|
|
|
|
|
if (isDataGatheringNeeded) {
|
|
|
|
|
Logger.log('7d data gathering has been started.');
|
|
|
|
|
Logger.log('7d data gathering has been started.', 'DataGatheringService');
|
|
|
|
|
console.time('data-gathering-7d');
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.create({
|
|
|
|
@ -64,7 +64,7 @@ export class DataGatheringService {
|
|
|
|
|
where: { key: PROPERTY_LAST_DATA_GATHERING }
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Logger.error(error);
|
|
|
|
|
Logger.error(error, 'DataGatheringService');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.delete({
|
|
|
|
@ -73,7 +73,10 @@ export class DataGatheringService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Logger.log('7d data gathering has been completed.');
|
|
|
|
|
Logger.log(
|
|
|
|
|
'7d data gathering has been completed.',
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.timeEnd('data-gathering-7d');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -84,7 +87,10 @@ export class DataGatheringService {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!isDataGatheringLocked) {
|
|
|
|
|
Logger.log('Max data gathering has been started.');
|
|
|
|
|
Logger.log(
|
|
|
|
|
'Max data gathering has been started.',
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.time('data-gathering-max');
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.create({
|
|
|
|
@ -108,7 +114,7 @@ export class DataGatheringService {
|
|
|
|
|
where: { key: PROPERTY_LAST_DATA_GATHERING }
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Logger.error(error);
|
|
|
|
|
Logger.error(error, 'DataGatheringService');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.delete({
|
|
|
|
@ -117,7 +123,10 @@ export class DataGatheringService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Logger.log('Max data gathering has been completed.');
|
|
|
|
|
Logger.log(
|
|
|
|
|
'Max data gathering has been completed.',
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.timeEnd('data-gathering-max');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -128,7 +137,10 @@ export class DataGatheringService {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!isDataGatheringLocked) {
|
|
|
|
|
Logger.log(`Symbol data gathering for ${symbol} has been started.`);
|
|
|
|
|
Logger.log(
|
|
|
|
|
`Symbol data gathering for ${symbol} has been started.`,
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.time('data-gathering-symbol');
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.create({
|
|
|
|
@ -159,7 +171,7 @@ export class DataGatheringService {
|
|
|
|
|
where: { key: PROPERTY_LAST_DATA_GATHERING }
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Logger.error(error);
|
|
|
|
|
Logger.error(error, 'DataGatheringService');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.delete({
|
|
|
|
@ -168,7 +180,10 @@ export class DataGatheringService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Logger.log(`Symbol data gathering for ${symbol} has been completed.`);
|
|
|
|
|
Logger.log(
|
|
|
|
|
`Symbol data gathering for ${symbol} has been completed.`,
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.timeEnd('data-gathering-symbol');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -205,14 +220,17 @@ export class DataGatheringService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Logger.error(error);
|
|
|
|
|
Logger.error(error, 'DataGatheringService');
|
|
|
|
|
} finally {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async gatherProfileData(aDataGatheringItems?: IDataGatheringItem[]) {
|
|
|
|
|
Logger.log('Profile data gathering has been started.');
|
|
|
|
|
Logger.log(
|
|
|
|
|
'Profile data gathering has been started.',
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.time('data-gathering-profile');
|
|
|
|
|
|
|
|
|
|
let dataGatheringItems = aDataGatheringItems?.filter(
|
|
|
|
@ -248,7 +266,8 @@ export class DataGatheringService {
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Logger.error(
|
|
|
|
|
`Failed to enhance data for symbol ${symbol} by ${dataEnhancer.getName()}`,
|
|
|
|
|
error
|
|
|
|
|
error,
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -294,11 +313,18 @@ export class DataGatheringService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Logger.error(`${symbol}: ${error?.meta?.cause}`);
|
|
|
|
|
Logger.error(
|
|
|
|
|
`${symbol}: ${error?.meta?.cause}`,
|
|
|
|
|
error,
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.log('Profile data gathering has been completed.');
|
|
|
|
|
Logger.log(
|
|
|
|
|
'Profile data gathering has been completed.',
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
console.timeEnd('data-gathering-profile');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -361,7 +387,8 @@ export class DataGatheringService {
|
|
|
|
|
`Failed to gather data for symbol ${symbol} from ${dataSource} at ${format(
|
|
|
|
|
currentDate,
|
|
|
|
|
DATE_FORMAT
|
|
|
|
|
)}.`
|
|
|
|
|
)}.`,
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -377,14 +404,15 @@ export class DataGatheringService {
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
Logger.error(error);
|
|
|
|
|
Logger.error(error, 'DataGatheringService');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (symbolCounter > 0 && symbolCounter % 100 === 0) {
|
|
|
|
|
Logger.log(
|
|
|
|
|
`Data gathering progress: ${(
|
|
|
|
|
this.dataGatheringProgress * 100
|
|
|
|
|
).toFixed(2)}%`
|
|
|
|
|
).toFixed(2)}%`,
|
|
|
|
|
'DataGatheringService'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -474,7 +502,7 @@ export class DataGatheringService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async reset() {
|
|
|
|
|
Logger.log('Data gathering has been reset.');
|
|
|
|
|
Logger.log('Data gathering has been reset.', 'DataGatheringService');
|
|
|
|
|
|
|
|
|
|
await this.prismaService.property.deleteMany({
|
|
|
|
|
where: {
|
|
|
|
|