Bugfix/fix data gathering after seed (#390)

* Fix data gathering after seed

* Update changelog
pull/392/head
Thomas Kaul 3 years ago committed by GitHub
parent 554f2f861f
commit 6333aa972d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Hid the actions from the accounts table in the _Presenter View_ - Hid the actions from the accounts table in the _Presenter View_
- Hid the actions from the transactions table in the _Presenter View_ - Hid the actions from the transactions table in the _Presenter View_
- Fixed the data gathering of the initial project setup (database seeding)
### Todo ### Todo

@ -2,7 +2,7 @@ import {
benchmarks, benchmarks,
ghostfolioFearAndGreedIndexSymbol ghostfolioFearAndGreedIndexSymbol
} from '@ghostfolio/common/config'; } 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 { Injectable } from '@nestjs/common';
import { DataSource } from '@prisma/client'; import { DataSource } from '@prisma/client';
import { import {
@ -341,7 +341,12 @@ export class DataGatheringService {
} }
private async getSymbolsMax(): Promise<IDataGatheringItem[]> { 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 = const customSymbolsToGather =
await this.ghostfolioScraperApi.getCustomSymbolsToGather(startDate); await this.ghostfolioScraperApi.getCustomSymbolsToGather(startDate);
@ -356,14 +361,26 @@ export class DataGatheringService {
}; };
}); });
const symbolProfilesToGather = const symbolProfilesToGather = (
await this.prismaService.symbolProfile.findMany({ await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }], orderBy: [{ symbol: 'asc' }],
select: { select: {
dataSource: true, dataSource: true,
Order: {
orderBy: [{ date: 'asc' }],
select: { date: true },
take: 1
},
symbol: true symbol: true
} }
}); })
).map((item) => {
return {
dataSource: item.dataSource,
date: item.Order?.[0]?.date ?? startDate,
symbol: item.symbol
};
});
return [ return [
...this.getBenchmarksToGather(startDate), ...this.getBenchmarksToGather(startDate),

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

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

@ -6,7 +6,7 @@
</h3> </h3>
<mat-card class="mb-3"> <mat-card class="mb-3">
<mat-card-content> <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" i18n>Exchange Rates</div>
<div class="w-50"> <div class="w-50">
<div *ngFor="let exchangeRate of exchangeRates" class="mb-1"> <div *ngFor="let exchangeRate of exchangeRates" class="mb-1">

Loading…
Cancel
Save