fix: rinomina score.nome in score.elemento per coerenza con tabella pesi

This commit is contained in:
2026-08-21 19:17:03 +02:00
parent f16012c8bd
commit ad2fc0d510
2 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ CREATE TABLE IF NOT EXISTS score (
client_code TEXT NOT NULL REFERENCES soggetti(client_code), client_code TEXT NOT NULL REFERENCES soggetti(client_code),
sessione_id INTEGER NOT NULL REFERENCES sessioni(id), sessione_id INTEGER NOT NULL REFERENCES sessioni(id),
tipo TEXT NOT NULL CHECK (tipo IN ('asse','macro','fitness_age')), tipo TEXT NOT NULL CHECK (tipo IN ('asse','macro','fitness_age')),
nome TEXT NOT NULL, elemento TEXT NOT NULL,
valore REAL, valore REAL,
copertura REAL NOT NULL, copertura REAL NOT NULL,
stato TEXT NOT NULL CHECK (stato IN ('ok','insufficiente')), stato TEXT NOT NULL CHECK (stato IN ('ok','insufficiente')),
+5 -6
View File
@@ -35,7 +35,7 @@ describe('schema longevity', () => {
db.prepare(`INSERT INTO soggetti (client_code, sesso) VALUES ('ISL-0001', 'F')`).run(); db.prepare(`INSERT INTO soggetti (client_code, sesso) VALUES ('ISL-0001', 'F')`).run();
db.prepare(`INSERT INTO sessioni (client_code, data, tipo) VALUES ('ISL-0001', '2026-08-21', 'checkup')`).run(); db.prepare(`INSERT INTO sessioni (client_code, data, tipo) VALUES ('ISL-0001', '2026-08-21', 'checkup')`).run();
db.prepare( db.prepare(
`INSERT INTO score (client_code, sessione_id, tipo, nome, valore, copertura, stato, model_version) `INSERT INTO score (client_code, sessione_id, tipo, elemento, valore, copertura, stato, model_version)
VALUES ('ISL-0001', 1, 'asse', 'Forza & Struttura', NULL, 0.2, 'insufficiente', 'v1.0')` VALUES ('ISL-0001', 1, 'asse', 'Forza & Struttura', NULL, 0.2, 'insufficiente', 'v1.0')`
).run(); ).run();
const row = db.prepare(`SELECT valore, stato FROM score`).get() as { valore: number | null; stato: string }; const row = db.prepare(`SELECT valore, stato FROM score`).get() as { valore: number | null; stato: string };
@@ -49,12 +49,11 @@ describe('schema longevity', () => {
expect(cols).toEqual(expect.arrayContaining(['client_code', 'user_id', 'nome', 'cognome', 'data_nascita'])); expect(cols).toEqual(expect.arrayContaining(['client_code', 'user_id', 'nome', 'cognome', 'data_nascita']));
const lg = createLongevityDb(':memory:'); const lg = createLongevityDb(':memory:');
// Esclude la tabella score (che ha una colonna nome legittima per il nome dello score calcolato). const tutte = (lg.prepare(`SELECT name FROM sqlite_master WHERE type='table'`).all() as { name: string }[])
// Controlla che le colonne identificative della PERSONA non stiano nel longevity.
const colonne = (lg.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name != 'score'`).all() as { name: string }[])
.flatMap((t) => (lg.prepare(`PRAGMA table_info(${t.name})`).all() as { name: string }[]).map((c) => c.name)); .flatMap((t) => (lg.prepare(`PRAGMA table_info(${t.name})`).all() as { name: string }[]).map((c) => c.name));
expect(colonne).not.toContain('cognome'); expect(tutte).not.toContain('nome');
expect(colonne).not.toContain('data_nascita'); expect(tutte).not.toContain('cognome');
expect(tutte).not.toContain('data_nascita');
}); });
it('la soglia di copertura e 0.40', () => { it('la soglia di copertura e 0.40', () => {