From a2aec38da5a2548b1f3ae7a7636e50677e8b90e2 Mon Sep 17 00:00:00 2001 From: Jah-yee <166608075+Jah-yee@users.noreply.github.com> Date: Wed, 3 Jun 2026 02:23:02 +0800 Subject: [PATCH] fix: use CSV header to resolve column indices dynamically Replace hardcoded column indexes (row[1] for language, row[4] for comments) with dynamic lookup from the CSV header row. This prevents filtering and sorting from silently breaking if column order changes. Fixes #108. --- app/frontend/index.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/frontend/index.html b/app/frontend/index.html index 829534e..e193ae8 100644 --- a/app/frontend/index.html +++ b/app/frontend/index.html @@ -64,6 +64,7 @@

Good First Issues

let currentSearch = ""; let currentLanguage = ""; let sortMode = 0; + let colIdx = {}; /* 0 = DEFAULT 1 = DESCENDING @@ -118,17 +119,17 @@

Good First Issues

if (currentLanguage !== "") { rows = rows.filter(row => { - return row[1] === currentLanguage + return row[colIdx.language] === currentLanguage }); } if (sortMode === 1) { rows.sort( - (a,b) => Number(b[4]) - Number(a[4]) + (a,b) => Number(b[colIdx.comments]) - Number(a[colIdx.comments]) ); } else if (sortMode === 2) { rows.sort( - (a,b) => Number(a[4]) - Number(b[4]) + (a,b) => Number(a[colIdx.comments]) - Number(b[colIdx.comments]) ); } @@ -174,10 +175,15 @@

Good First Issues

skipEmptyLines: true, complete: function(results) { issuesData = results.data; + const header = issuesData[0]; + colIdx = { + language: header.indexOf("language"), + comments: header.indexOf("comments") + }; const languages = [ ...new Set( - issuesData.slice(1).map(row => row[1]) + issuesData.slice(1).map(row => row[colIdx.language]) ) ];