Browse Source

Fix data gathering after seed

pull/390/head
Thomas 4 years ago
parent
commit
9237fa5def
  1. 23
      apps/api/src/services/data-gathering.service.ts
  2. 5
      apps/api/src/services/data-provider/data-provider.service.ts
  3. 2
      apps/api/src/services/exchange-rate-data.service.ts
  4. 2
      apps/client/src/app/pages/admin/admin-page.html

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

@ -2,7 +2,7 @@ import {
benchmarks,
ghostfolioFearAndGreedIndexSymbol
} from '@ghostfolio/common/config';
import { DATE_FORMAT, getUtc, resetHours } from '@ghostfolio/common/helper';
import { DATE_FORMAT, resetHours } from '@ghostfolio/common/helper';
import { Injectable } from '@nestjs/common';
import { DataSource } from '@prisma/client';
import {
@ -341,7 +341,12 @@ export class DataGatheringService {
}
private async getSymbolsMax(): Promise<IDataGatheringItem[]> {
const startDate = new Date(getUtc('2015-01-01'));
const startDate =
(
await this.prismaService.order.findFirst({
orderBy: [{ date: 'asc' }]
})
)?.date ?? new Date();
const customSymbolsToGather =
await this.ghostfolioScraperApi.getCustomSymbolsToGather(startDate);
@ -356,13 +361,25 @@ export class DataGatheringService {
};
});
const symbolProfilesToGather =
const symbolProfilesToGather = (
await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }],
select: {
dataSource: true,
Order: {
orderBy: [{ date: 'asc' }],
select: { date: true },
take: 1
},
symbol: true
}
})
).map((item) => {
return {
dataSource: item.dataSource,
date: item.Order?.[0]?.date ?? startDate,
symbol: item.symbol
};
});
return [

5
apps/api/src/services/data-provider/data-provider.service.ts

@ -11,6 +11,7 @@ import { Granularity } from '@ghostfolio/common/types';
import { Injectable } from '@nestjs/common';
import { DataSource, MarketData } from '@prisma/client';
import { format } from 'date-fns';
import { isEmpty } from 'lodash';
import { AlphaVantageService } from './alpha-vantage/alpha-vantage.service';
import { GhostfolioScraperApiService } from './ghostfolio-scraper-api/ghostfolio-scraper-api.service';
@ -77,6 +78,10 @@ export class DataProviderService {
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
} = {};
if (isEmpty(aItems)) {
return response;
}
const granularityQuery =
aGranularity === 'month'
? `AND (date_part('day', date) = 1 OR date >= TIMESTAMP 'yesterday')`

2
apps/api/src/services/exchange-rate-data.service.ts

@ -135,7 +135,7 @@ export class ExchangeRateDataService {
}
}
if (isNumber(factor)) {
if (isNumber(factor) && !isNaN(factor)) {
return factor * aValue;
}

2
apps/client/src/app/pages/admin/admin-page.html

@ -6,7 +6,7 @@
</h3>
<mat-card class="mb-3">
<mat-card-content>
<div class="d-flex my-3">
<div *ngIf="exchangeRates?.length > 0" class="d-flex my-3">
<div class="w-50" i18n>Exchange Rates</div>
<div class="w-50">
<div *ngFor="let exchangeRate of exchangeRates" class="mb-1">

Loading…
Cancel
Save