Skip to content

Commit e746e79

Browse files
committed
Refactor ranking controller to use single quotes for string literals and improve code consistency
1 parent 666222a commit e746e79

File tree

1 file changed

+14
-14
lines changed
  • functions/src/controllers/v1/ranking

1 file changed

+14
-14
lines changed

functions/src/controllers/v1/ranking/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Request, Response } from "express";
2-
import { DB, resultsCollection, studentsCollection } from "../../../db";
3-
import { GetRankingResponse, Result, Student } from "types";
1+
import { Request, Response } from 'express';
2+
import { DB, resultsCollection, studentsCollection } from '../../../db';
3+
import { GetRankingResponse, Result, Student } from 'types';
44

55
const getStudentDetailByAdmissionNo = async (admissionNo: string) => {
66
const student = await DB.collection(studentsCollection)
@@ -32,15 +32,15 @@ export async function rankingController(req: Request, res: Response) {
3232
if (isNaN(numericClass)) {
3333
// For string classes like 'ukg', 'lkg', 'nursery'
3434
classQuery = DB.collection(collection).where(
35-
"currentClass",
36-
"==",
35+
'currentClass',
36+
'==',
3737
className
3838
);
3939
} else {
4040
// For numeric classes like 1, 2, etc
4141
classQuery = DB.collection(collection)
42-
.where("currentClass", "==", numericClass)
43-
.where("isCompleted", "==", true);
42+
.where('currentClass', '==', numericClass)
43+
.where('isCompleted', '==', true);
4444
}
4545

4646
const results = await classQuery.get();
@@ -86,26 +86,26 @@ export async function rankingController(req: Request, res: Response) {
8686
(a, b) => Number(b.percentage) - Number(a.percentage)
8787
);
8888

89-
if (content === "csv") {
90-
const csvHeader = "name,roll,totalMarks,obtainedMarks,percentage,rank\n";
89+
if (content === 'csv') {
90+
const csvHeader = 'name,roll,totalMarks,obtainedMarks,percentage,rank\n';
9191
const csvRows = sortedDetails.map(
9292
(detail, index) =>
9393
`${detail.name},${detail.roll},${detail.totalMarks},${
9494
detail.obtainedMarks
9595
},${detail.percentage},${index + 1}`
9696
);
97-
const csvContent = csvHeader + csvRows.join("\n");
97+
const csvContent = csvHeader + csvRows.join('\n');
9898

99-
res.setHeader("Content-Type", "text/csv");
99+
res.setHeader('Content-Type', 'text/csv');
100100
res.setHeader(
101-
"Content-Disposition",
101+
'Content-Disposition',
102102
`attachment; filename=ranking-${batch}-${term}-${className}.csv`
103103
);
104-
return res.status(200).send(csvContent);
104+
res.status(200).send(csvContent);
105105
}
106106

107107
const response: GetRankingResponse = {
108-
message: "success",
108+
message: 'success',
109109
success: true,
110110
data: sortedDetails.map((detail, index) => ({
111111
name: detail.name,

0 commit comments

Comments
 (0)