Refactor JSON optimizer script and update data fetching logic for improved performance

This commit is contained in:
fynks 2025-09-30 09:40:53 +05:00
parent 7694bdad22
commit d110a106ad
3 changed files with 5 additions and 7 deletions

1
dist/index.html vendored
View file

@ -39,7 +39,6 @@
<!-- Prefetch data for quick subsequent use (non-blocking) -->
<link rel="prefetch" as="fetch" href="/json/file-hosts-optimized.json" crossorigin>
<link rel="prefetch" as="fetch" href="/json/adult-hosts-optimized.json" crossorigin>
<link rel="prefetch" as="fetch" href="/json/pricing.json" crossorigin>
<link as="style" rel="preload" href="/css/styles-min.css">
<script>

3
dist/js/app.js vendored
View file

@ -1002,8 +1002,7 @@ document.addEventListener('DOMContentLoaded', async () => {
// Prefer optimized JSON, fall back to original if missing
const datasets = [
['./json/file-hosts-optimized.json', './json/file-hosts.json'],
['./json/adult-hosts-optimized.json', './json/adult-hosts.json'],
['./json/pricing.json']
['./json/adult-hosts-optimized.json', './json/adult-hosts.json']
];
const fetchPromises = datasets.map(list => fetchJsonFallback(list, 8000));

View file

@ -1,9 +1,9 @@
#!/bin/bash
# JSON Optimizer Script - Converts host data to indexed format
# Converts ✅/❌ format to compact indexed format for better performance
# Usage: ./scripts/json-optimizer.sh file-hosts.json
# ./scripts/json-optimizer.sh adult-hosts.json
# ./scripts/json-optimizer.sh pricing.json
# Colors for output
RED='\033[0;31m'
@ -41,7 +41,7 @@ if [ $# -eq 0 ]; then
echo "Examples:"
echo " $0 file-hosts.json"
echo " $0 ./json/adult-hosts.json"
echo " $0 pricing.json pricing-optimized.json"
echo " $0 ./json/file-hosts.json file-hosts-optimized.json"
exit 1
fi
@ -118,11 +118,11 @@ def convert_to_indexed_format(input_file, output_file):
total_support_instances = 0
for host, host_data in data.items():
# Get indices of services with 'yes' values (case insensitive)
# Get indices of services with '✅' values (new format)
supported_indices = [
service_to_index[service]
for service, value in host_data.items()
if str(value).lower() == 'yes'
if str(value) == '✅'
]
supported[host] = sorted(supported_indices)
total_support_instances += len(supported_indices)