Browse Source

Feature/change data gathering selection (#368)

* Change data gathering selection from distinct orders to symbol profiles

* Update changelog
pull/369/head
Thomas Kaul 3 years ago
committed by GitHub
parent
commit
4a815d2031
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 39
      apps/api/src/services/data-gathering.service.ts
  3. 2
      prisma/migrations/20210913190808_changed_currency_to_optional_in_order/migration.sql
  4. 2
      prisma/schema.prisma

1
CHANGELOG.md

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Optimized the annualized performance calculation
- Changed the data gathering selection from distinct orders to symbol profiles
## 1.52.0 - 11.09.2021

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

@ -309,24 +309,17 @@ export class DataGatheringService {
private async getSymbols7D(): Promise<IDataGatheringItem[]> {
const startDate = subDays(resetHours(new Date()), 7);
const distinctOrders = await this.prismaService.order.findMany({
distinct: ['symbol'],
const symbolProfilesToGather = (
await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }],
select: { dataSource: true, symbol: true },
where: {
date: {
lt: endOfToday() // no draft
select: {
dataSource: true,
symbol: true
}
}
});
const distinctOrdersWithDate: IDataGatheringItem[] = distinctOrders
.filter((distinctOrder) => {
return !isGhostfolioScraperApiSymbol(distinctOrder.symbol);
})
.map((distinctOrder) => {
).map((symbolProfile) => {
return {
...distinctOrder,
...symbolProfile,
date: startDate
};
});
@ -348,7 +341,7 @@ export class DataGatheringService {
...this.getBenchmarksToGather(startDate),
...customSymbolsToGather,
...currencyPairsToGather,
...distinctOrdersWithDate
...symbolProfilesToGather
];
}
@ -368,14 +361,12 @@ export class DataGatheringService {
}
);
const distinctOrders = await this.prismaService.order.findMany({
distinct: ['symbol'],
orderBy: [{ date: 'asc' }],
select: { dataSource: true, date: true, symbol: true },
where: {
date: {
lt: endOfToday() // no draft
}
const symbolProfilesToGather =
await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }],
select: {
dataSource: true,
symbol: true
}
});
@ -383,7 +374,7 @@ export class DataGatheringService {
...this.getBenchmarksToGather(startDate),
...customSymbolsToGather,
...currencyPairsToGather,
...distinctOrders
...symbolProfilesToGather
];
}

2
prisma/migrations/20210913190808_changed_currency_to_optional_in_order/migration.sql

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Order" ALTER COLUMN "currency" DROP NOT NULL;

2
prisma/schema.prisma

@ -76,7 +76,7 @@ model Order {
accountId String?
accountUserId String?
createdAt DateTime @default(now())
currency Currency
currency Currency?
dataSource DataSource @default(YAHOO)
date DateTime
fee Float

Loading…
Cancel
Save