Skip to content

Commit ce83d39

Browse files
Merge pull request #260 from abhitrueprogrammer/prod
remove paper count
2 parents e60f841 + ef682b8 commit ce83d39

5 files changed

Lines changed: 87 additions & 54 deletions

File tree

next.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ await import("./src/env.js");
77
/** @type {import("next").NextConfig} */
88
const config = {
99
swcMinify: false,
10-
1110
images: {
1211
domains: ["res.cloudinary.com"],
1312
},

src/components/Searchbar/searchbar-child.tsx

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ function SearchBarChild({
1717
const router = useRouter();
1818
const [searchText, setSearchText] = useState("");
1919
const [suggestions, setSuggestions] = useState<string[]>([]);
20-
const [subjectCounts, setSubjectCounts] = useState<Record<string, number>>(
21-
{},
22-
);
20+
// const [subjectCounts, setSubjectCounts] = useState<Record<string, number>>(
21+
// {},
22+
// );
2323
const suggestionsRef = useRef<HTMLUListElement | null>(null);
2424
const fuzzy = new Fuse(initialSubjects);
2525

26-
const fetchPaperCount = async (subjectName: string) => {
27-
try {
28-
const cleanSubject = subjectName.replace(/^"|"$/g, "");
29-
const encodedSubject = encodeURIComponent(cleanSubject);
26+
// const fetchPaperCount = async (subjectName: string) => {
27+
// try {
28+
// const cleanSubject = subjectName.replace(/^"|"$/g, "");
29+
// const encodedSubject = encodeURIComponent(cleanSubject);
3030

31-
const response = await axios.get<{ count: number }>(
32-
`/api/papers/count?subject=${encodedSubject}`,
33-
);
31+
// const response = await axios.get<{ count: number }>(
32+
// `/api/papers/count?subject=${encodedSubject}`,
33+
// );
3434

35-
return response.data.count ?? 0;
36-
} catch (error) {
37-
console.error("Error fetching count for", subjectName, error);
38-
return 0;
39-
}
40-
};
35+
// return response.data.count ?? 0;
36+
// } catch (error) {
37+
// console.error("Error fetching count for", subjectName, error);
38+
// return 0;
39+
// }
40+
// };
4141

4242
const handleSearchChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
4343
const text = e.target.value;
@@ -55,25 +55,25 @@ function SearchBarChild({
5555
setSuggestions(filteredSuggestions);
5656

5757
// Fetch counts in parallel for each suggestion
58-
const counts = await Promise.all(
59-
filteredSuggestions.map(async (subject) => {
60-
const count = await fetchPaperCount(subject);
61-
return { subject, count };
62-
}),
63-
);
64-
65-
const countsMap = counts.reduce(
66-
(acc, { subject, count }) => {
67-
acc[subject] = count;
68-
return acc;
69-
},
70-
{} as Record<string, number>,
71-
);
72-
73-
setSubjectCounts(countsMap);
58+
// const counts = await Promise.all(
59+
// filteredSuggestions.map(async (subject) => {
60+
// const count = await fetchPaperCount(subject);
61+
// return { subject, count };
62+
// }),
63+
// );
64+
65+
// const countsMap = counts.reduce(
66+
// (acc, { subject, count }) => {
67+
// acc[subject] = count;
68+
// return acc;
69+
// },
70+
// {} as Record<string, number>,
71+
// );
72+
73+
// setSubjectCounts(countsMap);
7474
} else {
7575
setSuggestions([]);
76-
setSubjectCounts({});
76+
// setSubjectCounts({});
7777
}
7878
};
7979

@@ -137,12 +137,12 @@ function SearchBarChild({
137137
onClick={() => handleSelectSuggestion(suggestion)}
138138
className="flex cursor-pointer items-center rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-800"
139139
>
140-
<div
140+
{/* <div
141141
id="paper_count"
142142
className="mr-4 flex h-10 w-10 items-center justify-center rounded-md bg-[#171720] text-sm font-semibold text-white"
143143
>
144144
{subjectCounts[suggestion] ?? "0"}
145-
</div>
145+
</div> */}
146146
<span
147147
id="subject"
148148
className="items-center text-sm tracking-wide text-black dark:text-white sm:text-base"

src/components/UpcomingPaper.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface PaperCardProps {
1717
export default function PaperCard({ subject, slots }: PaperCardProps) {
1818
const courseName = extractWithoutBracketContent(subject);
1919
const courseCode = extractBracketContent(subject);
20-
const [paperCount, setPaperCount] = useState<number | null>(0);
20+
// const [paperCount, setPaperCount] = useState<number | null>(0);
2121
const [pinned, setPinned] = useState<boolean>(false);
2222

2323
const handlePinToggle = () => {
@@ -36,19 +36,19 @@ export default function PaperCard({ subject, slots }: PaperCardProps) {
3636
};
3737

3838
useEffect(() => {
39-
const fetchPaperCount = async () => {
40-
try {
41-
const response = await axios.get<{ count: number }>(
42-
"/api/papers/count",
43-
{
44-
params: { subject },
45-
},
46-
);
47-
setPaperCount(response.data.count);
48-
} catch (error) {
49-
console.error("Failed to fetch paper count:", error);
50-
}
51-
};
39+
// const fetchPaperCount = async () => {
40+
// try {
41+
// const response = await axios.get<{ count: number }>(
42+
// "/api/papers/count",
43+
// {
44+
// params: { subject },
45+
// },
46+
// );
47+
// setPaperCount(response.data.count);
48+
// } catch (error) {
49+
// console.error("Failed to fetch paper count:", error);
50+
// }
51+
// };
5252

5353
const currentPinnedSubjects = JSON.parse(
5454
localStorage.getItem("userSubjects") ?? "[]",
@@ -62,7 +62,7 @@ export default function PaperCard({ subject, slots }: PaperCardProps) {
6262
}
6363
}
6464

65-
void fetchPaperCount();
65+
// void fetchPaperCount();
6666
}, [subject]);
6767

6868
const router = useRouter();
@@ -82,9 +82,9 @@ export default function PaperCard({ subject, slots }: PaperCardProps) {
8282
<div className="flex items-start justify-between">
8383
<h2 className="rounded-t-lg px-2 py-1 font-play text-base font-bold md:text-lg md:tracking-widest">
8484
{courseCode}
85-
<div className="text-sm font-normal">
85+
{/* <div className="text-sm font-normal">
8686
{paperCount ? `Papers available: ${paperCount}` : "Click to explore"}
87-
</div>
87+
</div> */}
8888
</h2>
8989

9090
<button

src/lib/mongoose.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export async function connectToDatabase() {
2525
cached.promise = mongoose.connect(MONGODB_URI, {
2626
maxConnecting: 2,
2727
bufferCommands: false,
28-
maxPoolSize: 10,
2928
}).then((mongoose) => {
3029
return mongoose;
3130
});

vercel.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"headers": [
4+
{
5+
"source": "/api/upcoming-papers",
6+
"headers": [
7+
{ "key": "Cache-Control", "value": "s-maxage=60, stale-while-revalidate=120" }
8+
]
9+
},
10+
{
11+
"source": "/api/papers",
12+
"headers": [
13+
{ "key": "Cache-Control", "value": "s-maxage=60, stale-while-revalidate=120" }
14+
]
15+
},
16+
{
17+
"source": "/api/selected-papers",
18+
"headers": [
19+
{ "key": "Cache-Control", "value": "s-maxage=60, stale-while-revalidate=120" }
20+
]
21+
},
22+
{
23+
"source": "/api/related-subject",
24+
"headers": [
25+
{ "key": "Cache-Control", "value": "s-maxage=60, stale-while-revalidate=120" }
26+
]
27+
},
28+
{
29+
"source": "/api/course-list",
30+
"headers": [
31+
{ "key": "Cache-Control", "value": "s-maxage=60, stale-while-revalidate=120" }
32+
]
33+
}
34+
]
35+
}

0 commit comments

Comments
 (0)