Browse Source

Cleaned up code

pull/2777/head
Hugo Persson 2 years ago
parent
commit
13a74464c3
  1. 6
      apps/api/src/app/admin/admin.controller.ts
  2. 14
      apps/api/src/services/data-gathering/data-gathering.service.ts
  3. 1
      apps/api/src/services/data-provider/manual/manual.service.ts
  4. 3
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

6
apps/api/src/app/admin/admin.controller.ts

@ -224,7 +224,6 @@ export class AdminController {
@Param('dataSource') dataSource: DataSource,
@Param('dateString') dateString: string,
@Param('symbol') symbol: string,
@Query('dryRun') isDryRun?: boolean
): Promise<MarketData> {
if (
!hasPermission(
@ -247,15 +246,10 @@ export class AdminController {
);
}
if (dataSource === 'MANUAL' && isDryRun && isToday(date)) {
//const marketData = await this.manualService.scrape()
Logger.log(`Check ${symbol} via scraperConfiguration`, dataSource);
}
return this.dataGatheringService.gatherSymbolForDate({
dataSource,
date,
isDryRun,
symbol
});
}

14
apps/api/src/services/data-gathering/data-gathering.service.ts

@ -84,12 +84,10 @@ export class DataGatheringService {
public async gatherSymbolForDate({
dataSource,
date,
isDryRun,
symbol
}: {
dataSource: DataSource;
date: Date;
isDryRun: boolean;
symbol: string;
}) {
try {
@ -102,18 +100,6 @@ export class DataGatheringService {
historicalData[symbol]?.[format(getYesterday(), DATE_FORMAT)]
.marketPrice;
if (isDryRun) {
const date = new Date();
return {
dataSource,
date,
marketPrice,
symbol,
createdAt: null,
id: null,
state: MarketDataState.INTRADAY
};
}
if (marketPrice) {
return await this.prismaService.marketData.upsert({

1
apps/api/src/services/data-provider/manual/manual.service.ts

@ -89,7 +89,6 @@ export class ManualService implements DataProviderInterface {
} else if (selector === undefined || url === undefined) {
return {};
}
Logger.log("Here");
const value = await this.scrape(url, selector, headers);

3
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -246,8 +246,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
.testScrapeConfig(this.assetProfileForm.controls['scraperConfiguration'].value)
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe((response) => {
if (response && response.price) {
console.log(response);
if (response?.price) {
alert($localize`Current Market Price is:` + ' ' + response.price);
} else {
alert($localize`Please try again.`);

Loading…
Cancel
Save