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 {
|
export interface RiskGroup {
|
||||||
/** the model's own title and the day it was scored (none: no model has scored her) */
|
/** the model's own title and the day it was scored (none: no model has scored her) */
|
||||||
title?: string;
|
title?: string;
|
||||||
|
scenario?: string;
|
||||||
index?: string;
|
index?: string;
|
||||||
scales: { label: string; risk?: Prediction }[];
|
scales: { label: string; risk?: Prediction }[];
|
||||||
}
|
}
|
||||||
@@ -55,6 +56,12 @@ const HORIZONS: [number, string][] = [
|
|||||||
[5, 'Riesgo a 5 años'],
|
[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
|
/** The scales the page draws: both horizons of every model, or, with no model, both horizons
|
||||||
* unavailable. */
|
* unavailable. */
|
||||||
export function riskGroups(
|
export function riskGroups(
|
||||||
@@ -63,7 +70,11 @@ export function riskGroups(
|
|||||||
const scales = (predictions: Prediction[]) =>
|
const scales = (predictions: Prediction[]) =>
|
||||||
HORIZONS.map(([years, label]) => ({ label, risk: horizon(predictions, years) }));
|
HORIZONS.map(([years, label]) => ({ label, risk: horizon(predictions, years) }));
|
||||||
return models.length
|
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([]) }];
|
: [{ scales: scales([]) }];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +130,9 @@ export function riskGroups(
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (g.index) {
|
@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