-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [performance improvement] #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,15 @@ export const getTalkSpeakersWithDetails = async (year: string | number, speakerI | |
|
|
||
| export const getRelatedTalksByTrack = async (year: string | number, track: string, excludeTalkId: string, limit: number = 5): Promise<Talk[]> => { | ||
| const allTalks = await getAllTalks(year); | ||
| const sameTracks = allTalks.filter((t) => getTrackFromTalk(t) === track && t.id !== excludeTalkId); | ||
| return sameTracks.slice(0, limit); | ||
| if (limit <= 0) return []; | ||
| const result: Talk[] = []; | ||
| for (const t of allTalks) { | ||
| if (getTrackFromTalk(t) === track && t.id !== excludeTalkId) { | ||
| result.push(t); | ||
| if (result.length >= limit) { | ||
| break; | ||
|
Comment on lines
+157
to
+158
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Normalize The previous Normalize the value before the loop, or reject non-integer limits. Use the normalized value in the break condition. Suggested fix+ const normalizedLimit = Math.floor(limit);
+ if (!(normalizedLimit > 0)) return [];
const result: Talk[] = [];
for (const t of allTalks) {
if (getTrackFromTalk(t) === track && t.id !== excludeTalkId) {
result.push(t);
- if (result.length >= limit) {
+ if (result.length === normalizedLimit) {
break;
}🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
| return result; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Move the non-positive-limit guard before
getAllTalks.Line 152 runs after Line 151 has already fetched and flattened all talks. A zero or negative limit still performs the full fetch and cache work. Move the guard, or its normalized equivalent, before the
await getAllTalks(year)call.🤖 Prompt for AI Agents