greyexploiter commited on
Commit
2446f40
·
verified ·
1 Parent(s): fff7a62
Files changed (1) hide show
  1. index.html +40 -8
index.html CHANGED
@@ -4,6 +4,7 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <title>ICMR Record Lookup</title>
 
7
  <style>
8
  body { background: #0f172a; color: #f8fafc; font-family: monospace; padding: 40px; }
9
  input, select, button { background: #1e293b; color: #fff; border: 1px solid #334155; padding: 10px; margin: 5px 0; font-family: monospace; }
@@ -16,31 +17,62 @@
16
  <div>
17
  <select id="type">
18
  <option value="phone">Phone Number</option>
19
- <option value="aadhar">Identifier</option>
20
  </select>
21
  <input type="text" id="query" placeholder="Enter query value..." style="width: 300px;">
22
  <button onclick="searchData()">Search</button>
23
  </div>
24
- <pre id="output">Ready. Select type and enter a value to search.</pre>
25
 
26
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  async function searchData() {
 
28
  const type = document.getElementById('type').value;
29
  const val = document.getElementById('query').value.trim();
30
  if (!val) return alert("Enter a search value");
31
 
32
- document.getElementById('output').innerText = "Querying records...";
 
 
33
  try {
34
- const endpoint = type === 'phone' ? '/api/icmr/phone' : '/api/icmr/aadhar';
35
- const param = type === 'phone' ? 'mobile' : 'aadhar';
 
 
 
 
 
 
36
 
37
- const res = await fetch(`https://phisherjr-worker.hf.space${endpoint}?${param}=${encodeURIComponent(val)}`);
38
- const data = await res.json();
39
- document.getElementById('output').innerText = JSON.stringify(data, null, 2);
 
 
40
  } catch (err) {
41
  document.getElementById('output').innerText = "Query Error: " + err.message;
 
 
42
  }
43
  }
 
 
44
  </script>
45
  </body>
46
  </html>
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <title>ICMR Record Lookup</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.28.0/dist/duckdb-browser.js"></script>
8
  <style>
9
  body { background: #0f172a; color: #f8fafc; font-family: monospace; padding: 40px; }
10
  input, select, button { background: #1e293b; color: #fff; border: 1px solid #334155; padding: 10px; margin: 5px 0; font-family: monospace; }
 
17
  <div>
18
  <select id="type">
19
  <option value="phone">Phone Number</option>
20
+ <option value="aadharNumber">Identifier / Aadhaar</option>
21
  </select>
22
  <input type="text" id="query" placeholder="Enter query value..." style="width: 300px;">
23
  <button onclick="searchData()">Search</button>
24
  </div>
25
+ <pre id="output">Initializing database engine...</pre>
26
 
27
  <script>
28
+ let db = null;
29
+
30
+ async function initDB() {
31
+ try {
32
+ const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
33
+ const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
34
+ const worker = new Worker(bundle.mainWorker);
35
+ const logger = new duckdb.ConsoleLogger();
36
+ db = new duckdb.AsyncDuckDB(logger, worker);
37
+ await db.instantiate(bundle.mainModule, bundle.workerWorker);
38
+ document.getElementById('output').innerText = "Engine ready. Enter a value to search.";
39
+ } catch (err) {
40
+ document.getElementById('output').innerText = "Initialization Error: " + err.message;
41
+ }
42
+ }
43
+
44
  async function searchData() {
45
+ if (!db) return alert("Engine still loading...");
46
  const type = document.getElementById('type').value;
47
  const val = document.getElementById('query').value.trim();
48
  if (!val) return alert("Enter a search value");
49
 
50
+ document.getElementById('output').innerText = "Querying parquet shards directly...";
51
+ const conn = await db.connect();
52
+
53
  try {
54
+ const targetFile = type === 'phone' ? 'idx_phone.*.parquet' : 'idx_aadhar.*.parquet';
55
+ const query = `
56
+ SELECT * FROM 'https://huggingface.co/datasets/greyexploiter/icrm-hitek-fulldb/resolve/main/${targetFile}'
57
+ WHERE ${type} = '${val}'
58
+ LIMIT 10;
59
+ `;
60
+ const result = await conn.query(query);
61
+ const rows = result.toArray().map(row => row.toJSON());
62
 
63
+ if (rows.length === 0) {
64
+ document.getElementById('output').innerText = "No matching records found.";
65
+ } else {
66
+ document.getElementById('output').innerText = JSON.stringify(rows, null, 2);
67
+ }
68
  } catch (err) {
69
  document.getElementById('output').innerText = "Query Error: " + err.message;
70
+ } finally {
71
+ await conn.close();
72
  }
73
  }
74
+
75
+ initDB();
76
  </script>
77
  </body>
78
  </html>