Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
jinddings committed Nov 27, 2024
2 parents c87bd00 + a47f075 commit 45cc34d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions BE/src/asset/asset.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ export class AssetController {
async updateAllAssets() {
await this.assetService.updateAllAssets();
}

@Cron('0 8 * * 1-5')
async updatePrevTotalAsset() {
await this.assetService.updatePrevTotalAsset();
}
}
8 changes: 7 additions & 1 deletion BE/src/asset/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export class AssetService {
total_profit: asset.cash_balance + totalPrice - 10000000,
total_profit_rate: (asset.cash_balance + totalPrice - 10000000) / 100000,
last_updated: new Date(),
prev_total_asset: asset.total_asset,
};
return this.assetRepository.save(updatedAsset);
}
Expand Down Expand Up @@ -162,4 +161,11 @@ export class AssetService {
this.stockPriceSocketService.unsubscribeByCode(userStock.stock_code),
);
}

async updatePrevTotalAsset() {
await this.assetRepository.update(
{},
{ prev_total_asset: () => 'total_asset' },
);
}
}
2 changes: 1 addition & 1 deletion BE/src/ranking/ranking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class RankingService {
};
}

@Cron('0 16 * * 1-5')
@Cron('*/1 * * * 1-5')
async updateRanking() {
const [profitRateRanking, assetRanking] = await Promise.all([
this.calculateRanking(SortType.PROFIT_RATE),
Expand Down
13 changes: 12 additions & 1 deletion FE/src/components/Mypage/MyStocksList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useNavigate } from 'react-router-dom';
import { MyStockListUnit } from 'types';
import { calcYield } from 'utils/common';

Expand All @@ -6,6 +7,12 @@ type MyStocksListProps = {
};

export default function MyStocksList({ stocks }: MyStocksListProps) {
const navigation = useNavigate();

const handleClick = (code: string) => {
navigation(`/stocks/${code}`);
};

return (
<div className='flex flex-col flex-1 w-full p-4 mx-auto bg-white rounded-md shadow-md'>
<div className='flex pb-2 text-sm font-bold border-b'>
Expand All @@ -23,7 +30,11 @@ export default function MyStocksList({ stocks }: MyStocksListProps) {
const stockYield = calcYield(avg_price, +stck_prpr);

return (
<li className='flex py-2' key={code}>
<li
className='flex py-2 transition-colors hover:cursor-pointer hover:bg-gray-50'
key={code}
onClick={() => handleClick(code)}
>
<div className='flex w-1/2 gap-2 text-left truncate'>
<p className='font-semibold'>{name}</p>
<p className='text-gray-500'>{code}</p>
Expand Down

0 comments on commit 45cc34d

Please sign in to comment.