Results: Simplify db load.

scenarios
Pierre-Antoine 2025-09-23 10:23:20 +02:00
parent f0ccf1f4f7
commit 936bfc753a
1 changed files with 2 additions and 5 deletions

View File

@ -119,16 +119,13 @@ class Results(SQLSubModel):
study = data['study'] study = data['study']
status = data['status'] status = data['status']
scenario = data["scenario"] scenario = data["scenario"]
loaded = data['loaded_pid']
values = execute( values = execute(
"SELECT pamhyr_id, solver_name, solver_type, " + "SELECT pamhyr_id, solver_name, solver_type, " +
"study_revision, creation_data, nb_timestamps, timestamps, " + "study_revision, creation_data, nb_timestamps, timestamps, " +
"scenario " + "scenario " +
"FROM results " + "FROM results " +
f"WHERE scenario = {scenario.id} " + f"WHERE scenario = {scenario.id}"
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
"ORDER BY ind ASC"
) )
for v in values: for v in values:
@ -155,9 +152,9 @@ class Results(SQLSubModel):
ts = struct.unpack(sf, timestamp_bytes) ts = struct.unpack(sf, timestamp_bytes)
new_results.set("timestamps", ts) new_results.set("timestamps", ts)
data["timestamps"] = ts
new_results._river = River._db_load(execute, data) new_results._river = River._db_load(execute, data)
loaded.add(pid)
new.append(new_results) new.append(new_results)
return new return new