Skip to content

Commit

Permalink
- Add web interface
Browse files Browse the repository at this point in the history
  • Loading branch information
PardhavMaradani committed Jul 21, 2024
1 parent 2bb0940 commit 719ee65
Show file tree
Hide file tree
Showing 8 changed files with 498 additions and 75 deletions.
91 changes: 16 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# NEET 2024 State / City / Center-wise marks DB

Click [here](https://pardhavmaradani.github.io/neet-2024-center-marks/) to explore the data directly in your browser.

- The centers data is obtained from the **NEET (UG) Result 2024 City/Center Wise** [link](https://neet.ntaonline.in/frontend/web/common-scorecard/index) as follows:
- The page shows there are `4,750` entries in the bottom left

Expand Down Expand Up @@ -39,81 +41,20 @@ sqlite>
$
```

- The DB can be analyzed in `sqlite` or any other DB program. Here is the table structure:
- To run a local version:
- Clone this repo
- Start a local server in the cloned folder using: `$ ./start_local_server.py`
- Open `http://localhost:8081/` in your browser

## Analyze

- Click [here](https://pardhavmaradani.github.io/neet-2024-center-marks/) to analyze this database in your browser
- Note that it could take a few seconds to download the DB and show the results
- The web interface should look something like this:



- Enter your **SQL** commands in the textarea and click on the `Execute` button to see the results.

```
$ sqlite3 neet-2024-center-marks-data.db
SQLite version 3.46.0 2024-05-23 13:25:27
Enter ".help" for usage hints.
sqlite> .tables
center_longnames center_marks centers
sqlite> .schema
CREATE TABLE centers(sno TEXT, state TEXT, city TEXT, name TEXT, centno NUMBER);
CREATE TABLE center_longnames(centno NUMBER, longname TEXT);
CREATE TABLE center_marks(centno NUMBER, sno NUMBER, marks NUMBER);
sqlite> .mode box
sqlite> select * from centers limit 5;
┌─────┬──────────────────────────────────┬────────────┬──────────────────────────────────────────┬────────┐
│ sno │ state │ city │ name │ centno │
├─────┼──────────────────────────────────┼────────────┼──────────────────────────────────────────┼────────┤
│ 1 │ ANDAMAN AND NICOBAR ISLANDS (UT) │ PORT BLAIR │ KENDRIYA VIDYALAYA NO. 1 │ 110101 │
│ 2 │ ANDAMAN AND NICOBAR ISLANDS (UT) │ PORT BLAIR │ DR B R AMBEDKAR INSTITUTE OF TECHNOLOGY │ 110102 │
│ 3 │ ANDAMAN AND NICOBAR ISLANDS (UT) │ PORT BLAIR │ GOVERNMENT MODEL SENIOR SECONDARY SCHOOL │ 110103 │
│ 4 │ ANDHRA PRADESH │ GUNTUR │ LITTLE FLOWER ENGLISH MEDIUM SCHOOL │ 120101 │
│ 5 │ ANDHRA PRADESH │ GUNTUR │ CHALAPATHI INSTITUTE OF TECHNOLOGY │ 120102 │
└─────┴──────────────────────────────────┴────────────┴──────────────────────────────────────────┴────────┘
sqlite> select count(*) from centers;
┌──────────┐
│ count(*) │
├──────────┤
│ 4750 │
└──────────┘
sqlite> select * from center_longnames limit 5;
┌────────┬──────────────────────────────────────────────────────────────┐
│ centno │ longname │
├────────┼──────────────────────────────────────────────────────────────┤
│ 990401 │ GLOBAL INDIAN INTERNATIONAL SCHOOL, 39/39 PATHUMTHANEE SAINA │
│ │ I ROAD MUANG PATHUMTHANEE 12000 THAILAND, BANGKOK, OUTSIDE-I │
│ │ NDIA │
├────────┼──────────────────────────────────────────────────────────────┤
│ 990501 │ SWAMI VIVEKANANDA GULTURAL GENTRE,, HIGH COMMISSION OF INDIA │
│ │ , 16/2 GREGORY''S ROAD, COLOMBO -07, SRI LANKA, COLOMBO, OUT │
│ │ SIDE-INDIA │
├────────┼──────────────────────────────────────────────────────────────┤
│ 990801 │ GLOBAL INDIAN INTERNATIONAL SCHOOL, KUALALUMPUR, MALAYSIA, 2 │
│ │ 42, LORONG ABDUL SAMAD, OFF, JIN SULTAN ABDUL SAMAD, BRICKFI │
│ │ ELDS, 50470KUALA LUMPUR, KUALA LUMPUR, OUTSIDE-INDIA │
├────────┼──────────────────────────────────────────────────────────────┤
│ 990901 │ INDIAN LANGUAGE SCHOOL, INDIAN LANGUAGE SCHOOL, 14/16, OBA N │
│ │ LE ARO AVENUE, ILUPEJU, LAGOS, NIGERIA, LAGOS, OUTSIDE-INDIA │
├────────┼──────────────────────────────────────────────────────────────┤
│ 261601 │ KENDRIYA VIDYALAYA LATEHAR, KINAMAR LATEHAR, LATEHAR, JHARKH │
│ │ AND │
└────────┴──────────────────────────────────────────────────────────────┘
sqlite> select count(*) from center_longnames;
┌──────────┐
│ count(*) │
├──────────┤
│ 4750 │
└──────────┘
sqlite> select * from center_marks limit 5;
┌────────┬─────┬───────┐
│ centno │ sno │ marks │
├────────┼─────┼───────┤
│ 990401 │ 1 │ 233 │
│ 990401 │ 2 │ 488 │
│ 990401 │ 3 │ 141 │
│ 990401 │ 4 │ 105 │
│ 990401 │ 5 │ 290 │
└────────┴─────┴───────┘
sqlite> select count(*) from center_marks;
┌──────────┐
│ count(*) │
├──────────┤
│ 2333162 │
└──────────┘
sqlite>
```

- The `neet-2024-center-marks-data.db` file can also be analyzed in any browser by using the `sql.js` [GUI sample](https://sql.js.org/examples/GUI/) and loading the `.db` file using the `Load an SQLite database file` option below the textarea.

21 changes: 21 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

.CodeMirror {
border: 1px solid #222;
height: auto;
}

.CodeMirror-scroll {
overflow-y: hidden;
overflow-x: auto;
}

.error {
color: red;
transition: .5s;
overflow: hidden;
margin: 15px;
}

#output {
overflow: auto;
}
File renamed without changes.
45 changes: 45 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf8">
<title>NEET 2024 Center-Wise Marks SQL Interface</title>
<!-- Begin Jekyll SEO tag v2.8.0 -->
<meta property="og:title" content="NEET 2024 Center-Wise Marks SQL Interface" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A browser based SQL Interface for NEET 2024 center-wise marks data, which allows you to explore and analyze using SQL queries." />
<meta property="og:description" content="A browser based SQL Interface for NEET 2024 center-wise marks data, which allows you to explore and analyze using SQL queries." />
<link rel="canonical" href="https://pardhavmaradani.github.io/neet-2024-center-marks/" />
<meta property="og:url" content="https://pardhavmaradani.github.io/neet-2024-center-marks/" />
<meta property="og:site_name" content="NEET 2024 Center-Wise Marks SQL Interface" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="NEET 2024 Center-Wise Marks SQL Interface" />
<!-- End Jekyll SEO tag -->

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.css">
<link rel="stylesheet" href="css/styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</head>

<body>
<div class="container">
<h1 class='mt-4 text-center'>NEET 2024 Center-Wise Marks SQL Interface</h1>
<label class="mt-4" for='commands'>Enter some SQL commands (<b>'Ctrl-Enter'</b> to execute):</label>
<div class="form-floating">
<textarea class="form-control" id="commands"></textarea>
</div>
<div class="mt-2 text-center">
<button id="execute" type="button" class="btn btn-primary">Execute</button>
</div>
<div id="error" class="mt-4 error"></div>
<div id="output" class="table-responsive">Please wait. Results will be displayed here...</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/mode/sql/sql.min.js"></script>
<script type="text/javascript" src="js/interact.js"></script>
</body>

</html>
111 changes: 111 additions & 0 deletions js/interact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Based on the sql.js GUI example at:
// https://github.com/sql-js/sql.js/blob/master/examples/GUI/gui.js

var execBtn = document.getElementById("execute");
var outputElm = document.getElementById('output');
var errorElm = document.getElementById('error');
var commandsElm = document.getElementById('commands');

// Start the worker in which sql.js will run
var worker = new Worker("js/worker.sql-wasm.js");
worker.onerror = error;

// Open a database
worker.postMessage({ action: 'open' });

// Connect to the HTML element we 'print' to
function print(text) {
outputElm.innerHTML = text.replace(/\n/g, '<br>');
}

function error(e) {
console.log(e);
errorElm.style.height = '2em';
errorElm.textContent = e.message;
}

function noerror() {
errorElm.style.height = '0';
}

// Run a command in the database
function execute(commands) {
worker.onmessage = function (event) {
var results = event.data.results;
if (!results) {
error({ message: event.data.error });
return;
}
outputElm.innerHTML = "";
for (var i = 0; i < results.length; i++) {
outputElm.appendChild(tableCreate(results[i].columns, results[i].values));
}
}
worker.postMessage({ action: 'exec', sql: commands });
outputElm.textContent = "Fetching results...";
}

// Create an HTML table
var tableCreate = function () {
function valconcat(vals, tagName) {
if (vals.length === 0) return '';
var open = '<' + tagName + '>', close = '</' + tagName + '>';
return open + vals.join(close + open) + close;
}
return function (columns, values) {
var tbl = document.createElement('table');
tbl.setAttribute("class", "table table-info table-striped table-bordered border-primary");
var html = '<thead>' + valconcat(columns, 'th') + '</thead>';
var rows = values.map(function (v) { return valconcat(v, 'td'); });
html += '<tbody>' + valconcat(rows, 'tr') + '</tbody>';
tbl.innerHTML = html;
return tbl;
}
}();

// Execute the commands when the button is clicked
function execEditorContents() {
noerror()
execute(editor.getValue() + ';');
}
execBtn.addEventListener("click", execEditorContents, true);

// Add syntax highlihjting to the textarea
var editor = CodeMirror.fromTextArea(commandsElm, {
mode: 'text/x-mysql',
viewportMargin: Infinity,
indentWithTabs: true,
smartIndent: true,
lineNumbers: true,
matchBrackets: true,
autofocus: true,
extraKeys: {
"Ctrl-Enter": execEditorContents,
}
});

// Fetch the database
async function fetchDB(){
const [buf] = await Promise.all([
fetch("db/neet-2024-center-marks-data.db").then(res => res.arrayBuffer())
]);
worker.onmessage = function () {
// Show the schema of the loaded database
editor.setValue("SELECT `name`, `sql` FROM `sqlite_master` WHERE type='table';\n" +
"SELECT * FROM centers LIMIT 5;\n" +
"SELECT count() AS 'No of Centers' FROM centers;\n" +
"SELECT * FROM center_longnames LIMIT 5;\n" +
"SELECT * FROM center_marks LIMIT 5;\n" +
"SELECT count() AS 'No of Students' FROM center_marks;\n"
);
execEditorContents();
};
try {
worker.postMessage({ action: 'open', buffer: buf }, [buf]);
}
catch (exception) {
worker.postMessage({ action: 'open', buffer: buf });
}
}

fetchDB();
Binary file added js/sql-wasm.wasm
Binary file not shown.
Loading

0 comments on commit 719ee65

Please sign in to comment.