Browse Source

Convert the symbol to uppercase to avoid case-sensitive duplicates

pull/514/head
Thomas 4 years ago
parent
commit
89d44f6b43
  1. 12
      apps/api/src/app/order/order.service.ts

12
apps/api/src/app/order/order.service.ts

@ -45,19 +45,22 @@ export class OrderService {
public async createOrder(data: Prisma.OrderCreateInput): Promise<Order> { public async createOrder(data: Prisma.OrderCreateInput): Promise<Order> {
const isDraft = isAfter(data.date as Date, endOfToday()); const isDraft = isAfter(data.date as Date, endOfToday());
// Convert the symbol to uppercase to avoid case-sensitive duplicates
const symbol = data.symbol.toUpperCase();
if (!isDraft) { if (!isDraft) {
// Gather symbol data of order in the background, if not draft // Gather symbol data of order in the background, if not draft
this.dataGatheringService.gatherSymbols([ this.dataGatheringService.gatherSymbols([
{ {
symbol,
dataSource: data.dataSource, dataSource: data.dataSource,
date: <Date>data.date, date: <Date>data.date
symbol: data.symbol
} }
]); ]);
} }
this.dataGatheringService.gatherProfileData([ this.dataGatheringService.gatherProfileData([
{ dataSource: data.dataSource, symbol: data.symbol } { symbol, dataSource: data.dataSource }
]); ]);
await this.cacheService.flush(); await this.cacheService.flush();
@ -65,7 +68,8 @@ export class OrderService {
return this.prismaService.order.create({ return this.prismaService.order.create({
data: { data: {
...data, ...data,
isDraft isDraft,
symbol
} }
}); });
} }

Loading…
Cancel
Save