Skip to content

Commit

Permalink
πŸ”§ fix: ν”„λ‘œκ·Έλž¨ μ‹œμž‘ μ‹œ μ’…λͺ© 쀑볡 ꡬ독 μ•ˆλ˜λ„λ‘ 둜직 μˆ˜μ • #53
Browse files Browse the repository at this point in the history
  • Loading branch information
sieunie committed Nov 13, 2024
1 parent 4910002 commit 16c34a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions BE/src/stock/order/stock-order.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export class StockOrderRepository extends Repository<Order> {
super(Order, dataSource.createEntityManager());
}

async findAllCodeByStatus() {
return this.createQueryBuilder('orders')
.select('DISTINCT orders.stock_code')
.getRawMany();
}

async updateOrderAndAssetWhenBuy(order, realPrice) {
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.startTransaction();
Expand Down
6 changes: 2 additions & 4 deletions BE/src/stock/order/stock-order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export class StockOrderService {

private readonly logger = new Logger();

async findAllPendingOrder() {
return this.stockOrderRepository.findBy({
status: StatusType.PENDING,
});
async findAllPendingOrderCode() {
return this.stockOrderRepository.findAllCodeByStatus();
}

async buy(userId: number, stockOrderRequest: StockOrderRequestDto) {
Expand Down
3 changes: 2 additions & 1 deletion BE/src/websocket/stock/price/stock-price-socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { BaseSocketService } from '../../base-socket.service';
import { SocketGateway } from '../../socket.gateway';
import { StockOrderService } from '../../../stock/order/stock-order.service';
import { Order } from '../../../stock/order/stock-order.entity';

@Injectable()
export class StockPriceSocketService {
Expand All @@ -19,7 +20,7 @@ export class StockPriceSocketService {
private readonly stockOrderService: StockOrderService,
) {
baseSocketService.registerSocketOpenHandler(async () => {
const orders = await stockOrderService.findAllPendingOrder();
const orders: Order[] = await stockOrderService.findAllPendingOrderCode();
orders.forEach((order) => {
baseSocketService.registerCode(this.TR_ID, order.stock_code);
});
Expand Down

0 comments on commit 16c34a5

Please sign in to comment.