chore: snapshot production code before Apple Design UI refinement
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
const base = 'http://115.29.187.205:20200';
|
||||
const date = '2026-08-25';
|
||||
const metrics = JSON.parse(await fs.readFile(new URL('./daily_metrics.json', import.meta.url), 'utf8'));
|
||||
const candidates = metrics.items
|
||||
.filter(x => String(x.platform_name || '').startsWith('现代') && Number(x.daily_mileage_km || 0) >= 10)
|
||||
.sort((a, b) => Number(b.daily_mileage_km) - Number(a.daily_mileage_km));
|
||||
|
||||
async function one(x) {
|
||||
const q = new URLSearchParams({
|
||||
protocol: 'GB32960', vin: x.vin,
|
||||
dateFrom: `${date} 00:00:00`, dateTo: `${date} 23:59:59`,
|
||||
orderBy: 'eventTime', limit: '1', offset: '0', includeFields: 'true',
|
||||
includePayload: 'false', includeTotal: 'true'
|
||||
});
|
||||
const res = await fetch(`${base}/api/history/raw-frames?${q}`);
|
||||
if (!res.ok) throw new Error(`${x.vin}: ${res.status}`);
|
||||
const body = await res.json();
|
||||
const f = body.items?.[0]?.parsed_fields || {};
|
||||
const required = [
|
||||
'gb32960.fuel_cell.max_hydrogen_pressure_mpa',
|
||||
'gb32960.fuel_cell.max_hydrogen_temperature_c',
|
||||
'gb32960.vehicle.soc_percent',
|
||||
'gb32960.vehicle.total_mileage_km',
|
||||
'gb32960.vehicle.vehicle_status',
|
||||
'gb32960.vehicle.charge_status'
|
||||
];
|
||||
return {...x, raw_total: Number(body.total || 0), first_has: required.filter(k => f[k] != null).length};
|
||||
}
|
||||
|
||||
const out = [];
|
||||
for (let i = 0; i < candidates.length; i += 12) {
|
||||
const batch = candidates.slice(i, i + 12);
|
||||
out.push(...await Promise.all(batch.map(one)));
|
||||
process.stderr.write(`checked ${Math.min(i + 12, candidates.length)}\n`);
|
||||
}
|
||||
await fs.writeFile(new URL('./candidate_assessment.json', import.meta.url), JSON.stringify(out, null, 2));
|
||||
const totals = out.map(x => x.raw_total).sort((a,b)=>a-b);
|
||||
console.log(JSON.stringify({count: out.length, min: totals[0], median: totals[Math.floor(totals.length/2)], max: totals.at(-1), complete_first_frame: out.filter(x=>x.first_has===6).length, prefixes: Object.entries(Object.groupBy(out, x=>x.vin.slice(0,3))).map(([prefix, rows]) => ({prefix, count: rows.length}))}, null, 2));
|
||||
Reference in New Issue
Block a user