Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion backend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const BASE_URL_11ST = process.env.BASE_URL_11ST as string;
export const MAX_TRACKING_RANK = parseInt(process.env.MAX_TRACKING_RANK || '50');
export const INVALIDATED_REFRESHTOKEN = 'invalidate refreshToken';
export const MONGODB_URL = process.env.MONGODB_URL as string;
export const KR_OFFSET = 9 * 60 * 60 * 1000;
export const THIRTY_DAYS = 30;
export const NINETY_DAYS = 90;
export const NO_CACHE = 0;
8 changes: 3 additions & 5 deletions backend/src/product/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ProductPrice } from 'src/schema/product.schema';
import { Model } from 'mongoose';
import { ProductPriceDto } from 'src/dto/product.price.dto';
import { PriceDataDto } from 'src/dto/price.data.dto';
import { KR_OFFSET, NINETY_DAYS, NO_CACHE, THIRTY_DAYS } from 'src/constants';
import { NINETY_DAYS, NO_CACHE, THIRTY_DAYS } from 'src/constants';
import { Cron } from '@nestjs/schedule';

const REGEXP_11ST =
Expand Down Expand Up @@ -88,9 +88,7 @@ export class ProductService {
where: { userId: userId },
relations: ['product'],
});
if (trackingProductList.length === 0) {
throw new HttpException('상품 목록을 찾을 수 없습니다.', HttpStatus.NOT_FOUND);
}
if (trackingProductList.length === 0) return [];
const trackingListInfo = trackingProductList.map(async ({ product, targetPrice }) => {
const { id, productName, productCode, shop, imageUrl } = product;
const { price } = this.productDataCache.get(id) ?? { price: NO_CACHE };
Expand Down Expand Up @@ -190,7 +188,7 @@ export class ProductService {
}

async getPriceData(productId: string, days: number): Promise<PriceDataDto[]> {
const endDate = new Date(+new Date() + KR_OFFSET);
const endDate = new Date();
const startDate = new Date(endDate);
startDate.setDate(endDate.getDate() - days);
const dataInfo = await this.productPriceModel
Expand Down
3 changes: 1 addition & 2 deletions backend/src/schema/product.schema.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import mongoose from 'mongoose';
import { KR_OFFSET } from 'src/constants';

@Schema({
timestamps: {
createdAt: 'time',
currentTime: () => new Date(+new Date() + KR_OFFSET),
currentTime: () => new Date(),
updatedAt: false,
},
})
Expand Down