Skip to content

Commit

Permalink
Fix: getTaxiFare -> getTaxiFareHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
ybmin committed Jul 21, 2024
1 parent 81a37da commit 7c48579
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/modules/fare.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const initializeDatabase = async () => {
},
{ fare: true }
)
.clone()
.lean()
).fare;
const fare = prevTaxiFare
? prevTaxiFare
Expand Down Expand Up @@ -139,7 +139,7 @@ const updateTaxiFare = async (sTime, isMajor) => {
time: sTime,
isMajor: isMajor,
})
.clone();
.lean();
await prevFares.reduce(async (acc, item) => {
const from = await locationModel.findOne({ _id: item.from });
const to = await locationModel.findOne({ _id: item.to });
Expand Down
4 changes: 2 additions & 2 deletions src/routes/docs/fare.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ fareDocs[`${apiPrefix}/getTaxiFare`] = {
},
},
500: {
description: "fare/getTaxiFare: Failed to load taxi fare",
description: "fare/getTaxiFareHandler: Failed to load taxi fare",
content: {
"text/html": {
example: "fare/getTaxiFare: Failed to load taxi fare",
example: "fare/getTaxiFareHandler: Failed to load taxi fare",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/schemas/fareSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { zodToSchemaObject } = require("../utils");
const { objectId } = require("../../../modules/patterns");

const fareZod = {
getTaxiFare: z.object({
getTaxiFareHandler: z.object({
from: z.string().regex(objectId),
to: z.string().regex(objectId),
time: z.string().datetime(),
Expand Down
2 changes: 1 addition & 1 deletion src/routes/fare.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const router = express.Router();

router.get(
"/getTaxiFare",
validateQuery(fareZod.getTaxiFare),
validateQuery(fareZod.getTaxiFareHandler),
getTaxiFareHandler
);

Expand Down
22 changes: 13 additions & 9 deletions src/services/fare.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ const getTaxiFareHandler = async (req, res) => {
});
return;
}
const from = await locationModel.findOne({
_id: { $eq: req.query.from },
});
const to = await locationModel.findOne({ _id: { $eq: req.query.to } });
const from = await locationModel
.findOne({
_id: { $eq: req.query.from },
})
.lean();
const to = await locationModel
.findOne({ _id: { $eq: req.query.to } })
.lean();
const sTime = scaledTime(new Date(req.query.time));

if (!from || !to) {
Expand All @@ -54,7 +58,7 @@ const getTaxiFareHandler = async (req, res) => {
);
}
)
.clone()
.lean()
).isMajor;
// 시간대별 정보 관리 (현재: 카이스트 본원 <-> 대전역)
if (isMajor) {
Expand All @@ -73,8 +77,8 @@ const getTaxiFareHandler = async (req, res) => {
);
}
)
.clone();
//만일 cron이 아직 돌지 않은 상태의 시간대의 정보를 필요로하는 비상시의 경우 대비
.lean();
//만일 초기화 되지 않은 시간대의 정보를 필요로하는 비상시의 경우 대비
if (!taxiFare || taxiFare.fare <= 0) {
await callTaxiFare(from, to)
.then((fare) => {
Expand Down Expand Up @@ -102,8 +106,8 @@ const getTaxiFareHandler = async (req, res) => {
);
}
)
.clone();
//만일 cron이 아직 돌지 않은 상태의 시간대의 정보를 필요로하는 비상시의 경우 대비
.lean();
//만일 초기화 되지 않은 시간대의 정보를 필요로하는 비상시의 경우 대비
if (!taxiFare || taxiFare.fare <= 0) {
await callTaxiFare(from, to)
.then((fare) => {
Expand Down

0 comments on commit 7c48579

Please sign in to comment.