Skip to content

Commit 49ad499

Browse files
authored
Merge pull request #59 from EasyToFind-ETF/dev
4차 배포
2 parents 99cb0c0 + 8787ace commit 49ad499

7 files changed

Lines changed: 118 additions & 121 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

controllers/saveTestResultController.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ const { saveTRService } = require("../services/saveTestResultService");
55
const saveTestResultController = {
66
saveTestResultPage: async (req, res) => {
77
const userId = req.user.user_id; // authMiddleware에서 넣어준 값
8-
const {
9-
mbtiType,
10-
stabilityWeight,
11-
liquidityWeight,
12-
growthWeight,
13-
divWeight,
14-
} = req.body;
15-
console.log("userId", userId);
8+
const { mbtiType, stabilityScore, liquidityScore, growthScore, divScore } =
9+
req.body;
10+
console.log(
11+
"savecontroller",
12+
stabilityScore,
13+
liquidityScore,
14+
growthScore,
15+
divScore
16+
);
1617

1718
try {
1819
const result = await saveTRService(
1920
userId,
2021
mbtiType,
21-
stabilityWeight,
22-
liquidityWeight,
23-
growthWeight,
24-
divWeight
22+
stabilityScore,
23+
liquidityScore,
24+
growthScore,
25+
divScore
2526
);
2627
// console.log("User ID:", userId);
2728
// console.log("MBTI Type:", mbtiType);

dao/getMainTrendDao.js

Lines changed: 66 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,81 @@
11
const getMainTrendDao = {
2-
getAumDao: async (connection) => {
2+
getAumDao: async (connection) => {
33
const query = `
4-
SELECT
5-
e.etf_code ,
6-
e.etf_name ,
7-
npd.close_price ,
8-
npd.trade_date
9-
FROM new_prices_daily npd
10-
JOIN etfs e ON npd.etf_code = e.etf_code
11-
WHERE npd.trade_date = (
12-
SELECT MAX(trade_date)
13-
FROM new_prices_daily
14-
)
15-
ORDER BY npd.aum DESC
16-
LIMIT 5;
4+
SELECT
5+
e.etf_code ,
6+
e.etf_name ,
7+
npd.close_price ,
8+
npd.trade_date ,
9+
npd.aum,
10+
erc.week1 ,
11+
e.is_retire_pension ,
12+
e.is_personal_pension
13+
FROM new_prices_daily npd
14+
JOIN etfs e ON npd.etf_code = e.etf_code
15+
join etf_return_cache erc on erc.etf_code = npd.etf_code
16+
WHERE npd.trade_date = (
17+
SELECT MAX(trade_date)
18+
FROM new_prices_daily
19+
)
20+
ORDER BY npd.aum DESC
21+
LIMIT 5;
1722
`;
23+
1824
const result = await connection.query(query);
25+
console.log("result", result);
1926
return result.rows;
20-
},
27+
},
2128

22-
getFlucDao: async (connection) => {
29+
getFlucDao: async (connection) => {
2330
const query = `
24-
SELECT
25-
e.etf_code ,
26-
e.etf_name ,
27-
npd.close_price ,
28-
npd.trade_date
29-
FROM new_prices_daily npd
30-
JOIN etfs e ON npd.etf_code = e.etf_code
31-
WHERE npd.trade_date = (
32-
SELECT MAX(trade_date)
33-
FROM new_prices_daily
34-
)
35-
ORDER BY npd.fluc_rt1 DESC
36-
LIMIT 5;
31+
32+
SELECT
33+
e.etf_code ,
34+
e.etf_name ,
35+
npd.close_price ,
36+
npd.trade_date ,
37+
npd.aum,
38+
erc.week1 ,
39+
e.is_retire_pension ,
40+
e.is_personal_pension
41+
FROM new_prices_daily npd
42+
JOIN etfs e ON npd.etf_code = e.etf_code
43+
join etf_return_cache erc on erc.etf_code = npd.etf_code
44+
WHERE npd.trade_date = (
45+
SELECT MAX(trade_date)
46+
FROM new_prices_daily
47+
)
48+
ORDER BY npd.fluc_rt1 DESC
49+
LIMIT 5;
3750
`;
3851
const result = await connection.query(query);
3952
return result.rows;
40-
},
53+
},
4154

42-
getVolumeDao: async (connection) => {
55+
getVolumeDao: async (connection) => {
4356
const query = `
44-
SELECT
45-
e.etf_code ,
46-
e.etf_name ,
47-
npd.close_price ,
48-
npd.trade_date
49-
FROM new_prices_daily npd
50-
JOIN etfs e ON npd.etf_code = e.etf_code
51-
WHERE npd.trade_date = (
52-
SELECT MAX(trade_date)
53-
FROM new_prices_daily
54-
)
55-
ORDER BY npd.volume DESC
56-
LIMIT 5;
57+
SELECT
58+
e.etf_code ,
59+
e.etf_name ,
60+
npd.close_price ,
61+
npd.trade_date ,
62+
npd.aum,
63+
erc.week1 ,
64+
e.is_retire_pension ,
65+
e.is_personal_pension
66+
FROM new_prices_daily npd
67+
JOIN etfs e ON npd.etf_code = e.etf_code
68+
join etf_return_cache erc on erc.etf_code = npd.etf_code
69+
WHERE npd.trade_date = (
70+
SELECT MAX(trade_date)
71+
FROM new_prices_daily
72+
)
73+
ORDER BY npd.volume DESC
74+
LIMIT 5;
5775
`;
58-
const result = await connection.query(query);
76+
const result = await connection.query(query);
5977
return result.rows;
60-
},
61-
};
78+
},
79+
};
6280

63-
module.exports = { getMainTrendDao };
81+
module.exports = { getMainTrendDao };

dao/getTestResultDao.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const getTestResultDao = {
77
divScore
88
) => {
99
const query = `
10-
WITH raw_score AS (
10+
WITH raw_score AS (
1111
SELECT
1212
ers.etf_code,
1313
e.etf_name,
@@ -37,12 +37,13 @@ ORDER BY total_score DESC
3737
LIMIT 5;
3838
`;
3939
console.log(
40-
"stabilityScore,liquidityScore,growthScore,divScore",
40+
"testDao",
4141
stabilityScore,
4242
liquidityScore,
4343
growthScore,
4444
divScore
4545
);
46+
4647
const result = await connection.query(query, [
4748
stabilityScore,
4849
liquidityScore,

dao/saveTestResultDao.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,39 @@ const saveTestResultDao = {
33
connection,
44
userId,
55
mbtiType,
6-
stabilityWeight,
7-
liquidityWeight,
8-
growthWeight,
9-
divWeight
6+
stabilityScore,
7+
liquidityScore,
8+
growthScore,
9+
divScore
1010
) => {
1111
const query = `
12-
UPDATE users SET
13-
mbti_type = $1,
14-
stability_weight = $2,
15-
liquidity_weight = $3,
16-
growth_weight = $4,
17-
diversification_weight = $5
18-
WHERE user_id = $6;
12+
UPDATE users SET
13+
mbti_type = $1,
14+
stability_weight = $2,
15+
liquidity_weight = $3,
16+
growth_weight = $4,
17+
diversification_weight = $5,
18+
updated_at = NOW()
19+
WHERE user_id = $6;
20+
1921
`;
2022

2123
console.log(
2224
"saveDao",
2325
mbtiType,
24-
stabilityWeight,
25-
liquidityWeight,
26-
growthWeight,
27-
divWeight,
26+
stabilityScore,
27+
liquidityScore,
28+
growthScore,
29+
divScore,
2830
userId
2931
);
3032

3133
const result = await connection.query(query, [
3234
mbtiType,
33-
stabilityWeight,
34-
liquidityWeight,
35-
growthWeight,
36-
divWeight,
35+
stabilityScore,
36+
liquidityScore,
37+
growthScore,
38+
divScore,
3739
userId,
3840
]);
3941

services/getTestResultService.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ const getTestResultService = {
1818
growthScore,
1919
divScore
2020
);
21-
console.log("service", result);
21+
console.log(
22+
"service",
23+
stabilityScore,
24+
liquidityScore,
25+
growthScore,
26+
divScore
27+
);
2228
if (result.length === 0) {
2329
throw new Error("No test results found");
2430
}

services/saveTestResultService.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ const saveTestResultService = {
55
saveTRService: async (
66
userId,
77
mbtiType,
8-
stabilityWeight,
9-
liquidityWeight,
10-
growthWeight,
11-
divWeight
8+
stabilityScore,
9+
liquidityScore,
10+
growthScore,
11+
divScore
1212
) => {
1313
const client = await pool.connect();
1414
try {
1515
const result = await saveTRDao(
1616
client,
1717
userId,
1818
mbtiType,
19-
stabilityWeight,
20-
liquidityWeight,
21-
growthWeight,
22-
divWeight
19+
stabilityScore,
20+
liquidityScore,
21+
growthScore,
22+
divScore
2323
);
2424
if (result.rowCount === 0) {
2525
throw new Error("Failed to save test result");

0 commit comments

Comments
 (0)