From d5a496e1d90de48e563cd995165128be32f65f0a Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Thu, 4 Jan 2024 19:12:29 +0530 Subject: show raw query --- index.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'index.html') diff --git a/index.html b/index.html index 1ead0d4..e5d5c7e 100644 --- a/index.html +++ b/index.html @@ -151,7 +151,7 @@ }, null, 2); } - function createTable(results, className) { + function createTable(results, className, rawQuery) { const result = results[0]; const columns = result.columns; const rows = result.values; @@ -190,6 +190,16 @@ table.appendChild(tbody); tableContainer.innerHTML = ""; tableContainer.appendChild(table); + + const pre = document.createElement("pre") + pre.innerHTML = rawQuery + + const details = document.createElement("details") + const summary = document.createElement("summary") + summary.innerText = "Raw SQL Query" + details.appendChild(summary) + details.appendChild(pre) + tableContainer.appendChild(details) } function getClassesByInstructor() { @@ -199,7 +209,7 @@ console.log(query); const results = db.exec(query); - createTable(results, "table-container") + createTable(results, "table-container", query) sorttable.makeSortable(document.getElementById("table-container").children[0]); } @@ -208,7 +218,7 @@ let query = `SELECT YearTerm as "YearTerms", insname1 as Instructor, AVG_GRD as "Average Grade", PCT_A as "% A", PCT_B as "% B", PCT_C_MINUS_OR_BELOW as "% C- and below", N_GRADE as "No. Graded" FROM raw_data WHERE Subject || ' ' || Course = '${classCode.toUpperCase()}';` const results = db.exec(query); - createTable(results, "table-container-class-codes") + createTable(results, "table-container-class-codes", query) sorttable.makeSortable(document.getElementById("table-container-class-codes").children[0]); } @@ -238,7 +248,7 @@ console.log(query); const results = db.exec(query); - createTable(results, "table-container-division") + createTable(results, "table-container-division", query) sorttable.makeSortable(document.getElementById("table-container-division").children[0]); } -- cgit v1.2.3