Ficha: titular cada riesgo por su desenlace y llevar el escenario al pie
This commit is contained in:
@@ -46,6 +46,7 @@ export function horizon(predictions: Prediction[], years: number): Prediction |
|
||||
export interface RiskGroup {
|
||||
/** the model's own title and the day it was scored (none: no model has scored her) */
|
||||
title?: string;
|
||||
scenario?: string;
|
||||
index?: string;
|
||||
scales: { label: string; risk?: Prediction }[];
|
||||
}
|
||||
@@ -55,6 +56,12 @@ const HORIZONS: [number, string][] = [
|
||||
[5, 'Riesgo a 5 años'],
|
||||
];
|
||||
|
||||
/** A model's published title, "Riesgo de X en <escenario> v1", as its outcome and its scenario. */
|
||||
export function titleParts(text: string): { title: string; scenario?: string } {
|
||||
const [, title, scenario] = /^(.*?)(?: en (.+?))?(?: v\d+)?$/.exec(text)!;
|
||||
return { title, scenario };
|
||||
}
|
||||
|
||||
/** The scales the page draws: both horizons of every model, or, with no model, both horizons
|
||||
* unavailable. */
|
||||
export function riskGroups(
|
||||
@@ -63,7 +70,11 @@ export function riskGroups(
|
||||
const scales = (predictions: Prediction[]) =>
|
||||
HORIZONS.map(([years, label]) => ({ label, risk: horizon(predictions, years) }));
|
||||
return models.length
|
||||
? models.map((m) => ({ title: m.text, index: m.index, scales: scales(m.predictions) }))
|
||||
? models.map((m) => ({
|
||||
...titleParts(m.text),
|
||||
index: m.index,
|
||||
scales: scales(m.predictions),
|
||||
}))
|
||||
: [{ scales: scales([]) }];
|
||||
}
|
||||
|
||||
@@ -119,7 +130,9 @@ export function riskGroups(
|
||||
</div>
|
||||
}
|
||||
@if (g.index) {
|
||||
<p class="muted foot">Fecha índice {{ g.index }}</p>
|
||||
<p class="muted foot">
|
||||
{{ g.scenario ? 'Escenario: ' + g.scenario + ' · ' : '' }}Fecha índice {{ g.index }}
|
||||
</p>
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user