Skip to content

Commit 6025d91

Browse files
committed
provide doubt sessions info in a separate api
1 parent 37f7326 commit 6025d91

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

components/student.component.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,39 @@ const getTestSeriesByGrade = async (grade, subject) => {
782782
}
783783
};
784784

785+
const getTestSeriesDoubtSessions = async (subject) => {
786+
try {
787+
const accessToken = await getZohoTokenOptimized();
788+
const zohoConfig = {
789+
headers: {
790+
"Content-Type": "application/json",
791+
"Access-Control-Allow-Origin": "*",
792+
Authorization: `Bearer ${accessToken}`,
793+
},
794+
};
795+
796+
const testSeriesQuery = `select Name, Zoom_Link,Recording_Link, Subject, Day, Time from Mock_Doubt_Sessions where Subject = '${subject}' limit 200`;
797+
798+
const [testSeries] = await Promise.all([
799+
limit(() => getAnalysisData(testSeriesQuery, zohoConfig)),
800+
]);
801+
802+
if (testSeries.status >= 204) {
803+
return {
804+
status: testSeries.status,
805+
data: [],
806+
};
807+
}
808+
809+
return {
810+
status: 200,
811+
data: testSeries.data.data,
812+
};
813+
} catch (error) {
814+
throw new Error(error);
815+
}
816+
};
817+
785818
module.exports = {
786819
getStudentDetails,
787820
getStudentOrders,
@@ -791,4 +824,5 @@ module.exports = {
791824
getPaymentHistory,
792825
sendStudentFeedback,
793826
getTestSeriesByGrade,
827+
getTestSeriesDoubtSessions,
794828
};

controllers/student.controller.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const {
88
getPaymentHistory,
99
sendStudentFeedback,
1010
getTestSeriesByGrade,
11+
getTestSeriesDoubtSessions,
1112
} = require("../components/student.component");
1213
const {
1314
getZohoTokenOptimized,
@@ -72,6 +73,24 @@ studentRouter.post("/test-series", authMiddleware, async (req, res) => {
7273
}
7374
});
7475

76+
studentRouter.post(
77+
"/test-series/doubt-session",
78+
authMiddleware,
79+
async (req, res) => {
80+
try {
81+
const { subject } = req.body;
82+
const data = await getTestSeriesDoubtSessions(subject);
83+
return res.status(200).send(data);
84+
} catch (error) {
85+
return res.status(error.status || 500).send({
86+
status: "error",
87+
message: error.message,
88+
code: error.status || 500,
89+
});
90+
}
91+
}
92+
);
93+
7594
studentRouter.post("/store/orders", authMiddleware, async (req, res) => {
7695
try {
7796
const { contactId } = req.body;

0 commit comments

Comments
 (0)