Skip to content

Commit

Permalink
[Fix] 차트 갱신시간 오류 수정
Browse files Browse the repository at this point in the history
- 차트 갱신시간 오류 수정 (연산자 수정)

Issues #122
  • Loading branch information
novice1993 committed Oct 3, 2023
1 parent 211b2a7 commit e9c2e3c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/hooks/useGetStockChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const useGetStockChart = (companyId: number) => {

const compareChartData = organizeData(data);
const compareMovingAvgData = calculateMovingAvgLine(averageLineMinute, compareChartData);
const compareData = setComparedMovingAvgChart(`${compareName}`, compareMovingAvgData);
const compareData = setComparedMovingAvgChart(compareName, compareMovingAvgData);
setCompare(compareData);
};

Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useGetStockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const useGetStockData = (companyId: number) => {
const isAfter330PM = currentHour > 15 || (currentHour === 15 && currentMinute >= 30);
const marketCloseTime = isBefore9AM || isAfter330PM;

const dataRenewalTime = isBusinessDay || !marketCloseTime;
const dataRenewalTime = isBusinessDay && !marketCloseTime;

// 시간대 (timeZone) 별로 queryKey를 다르게 설정해서, 서버 데이터가 동일할 때는 캐싱된 데이터 활용하고 서버 데이터가 갱신됐을 때는 새롭게 받아옴 (서버 데이터 30분마다 갱신)
const [month, day, hour, minute] = [currentTime.getMonth(), currentTime.getDate(), currentTime.getHours(), currentTime.getMinutes()];
const [month, day, hour, minute] = [currentTime.getMonth() + 1, currentTime.getDate(), currentTime.getHours(), currentTime.getMinutes()];
const timeZone = minute === 0 || minute === 30 ? "30 or 60" : 0 < minute && minute < 30 ? "1~29" : "31~59";
const queryKey = dataRenewalTime ? `chartData${companyId} ${month}${day}${hour}${timeZone}` : `chartData${companyId}`;

Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useGetStockInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const useGetStockInfo = (companyId: number) => {
const isAfter330PM = currentHour > 15 || (currentHour === 15 && currentMinute >= 30);
const marketCloseTime = isBefore9AM || isAfter330PM;

const dataRenewalTime = isBusinessDay || !marketCloseTime;
const dataRenewalTime = isBusinessDay && !marketCloseTime;

// 시간대 (timeZone) 별로 queryKey를 다르게 설정해서, 서버 데이터가 동일할 때는 캐싱된 데이터 활용하고 서버 데이터가 갱신됐을 때는 새롭게 받아옴 (서버 데이터 30분마다 갱신)
const [month, day, hour, minute] = [currentTime.getMonth(), currentTime.getDate(), currentTime.getHours(), currentTime.getMinutes()];
Expand Down

0 comments on commit e9c2e3c

Please sign in to comment.