// Quick first pass: one school at a time, Keep or Drop. Schools with hard problems (language you
// don't speak, unrelated subject, unsafe country) come first, with the reasons shown.
import { html, bar } from '../ui.js';
import { shortName, place, languageFit, subjectFit, netCost, moneyRange, monthlyGrant, money } from '../metrics.js';
/** Reasons a school is probably not worth comparing. Empty = nothing obviously wrong. */
export function concerns(s, app) {
const out = [];
const lang = languageFit(s, app.settings.languages);
if (lang.status === 'fail') out.push(`Language: ${lang.text.replace('✗ ', '')}`);
const subj = subjectFit(s);
if (subj.rank <= 1) out.push(`Subject area: ${subj.text}`);
const c = app.data.countries?.[s.country];
if (c && c.stabilityScore <= 3) out.push(`Country stability ${c.stabilityScore}/10 (MFA: ${c.mfaAdvisory?.level})`);
const r = s.research;
if (r && r.safety.score <= 3) out.push(`City safety ${r.safety.score}/10`);
if (r && r.aiRobotics.access.score <= 2) out.push(`Few relevant courses for you (access ${r.aiRobotics.access.score}/10)`);
return out;
}
export function render(root, app) {
const all = app.data.schools.map((s) => ({ s, st: app.state.stats.get(s.code) }));
const queue = all
.filter(({ st }) => !st.reviewed && !st.dropped)
.map((x) => ({ ...x, why: concerns(x.s, app) }))
.sort((x, y) => y.why.length - x.why.length);
const done = all.length - queue.length;
if (!queue.length) {
root.innerHTML = String(html`
Triage done
You've been through all ${all.length} schools. Now the comparisons do the rest.
Start comparing
`);
return;
}
const { s, why } = queue[0];
const r = s.research;
const n = netCost(s, app.settings, app.data);
const g = monthlyGrant(s, app.settings, app.data);
root.innerHTML = String(html`
${done} / ${all.length} reviewed
Optional first pass. Drop the obvious no-gos so your picks go to real candidates. Problem schools come first.
${s.flag}
${shortName(s)}
${place(s)}
${why.length ? html`${why.map((w) => html`- ${w}
`)}
` : ''}
${r ? html`
${r.summary}
- AI research
- ${bar(r.aiRobotics.academic.score)}
- Course access
- ${bar(r.aiRobotics.access.score)}
- Social / calm
- ${r.social.score} / ${r.solitude.score}
- Climb / hike / ocean
- ${r.nature.climbing.score} / ${r.nature.hiking.score} / ${r.nature.ocean.score}
- CTU money
- ${money(g.eur, app.settings, app.data)}/mo
- Out of pocket
- ${n ? moneyRange([n.lo, n.hi], app.settings, app.data, { compact: true }) : '–'}
${r.watchouts.length ? html`${r.watchouts.slice(0, 3).map((w) => html`- ${w}
`)}
` : ''}`
: html`Research pending: judge from the catalog for now, or keep it and decide later.
`}
`);
root.onclick = (e) => {
const t = e.target.closest('[data-action]');
if (!t) return;
if (t.dataset.action === 'drop') app.drop(s.code);
if (t.dataset.action === 'keep') app.review(s.code);
if (t.dataset.action === 'open') app.navigate(`#/school/${t.dataset.slug}`);
};
}