From 43ab6c447bfb3a1bde6ee899be811510c19137ee Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Tue, 17 Dec 2024 18:54:31 -0500 Subject: [PATCH] Make sure that we exclude measurements with null values in all data. --- src/stories/hubbles_law/database.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/stories/hubbles_law/database.ts b/src/stories/hubbles_law/database.ts index 0209d5f..aef50f5 100644 --- a/src/stories/hubbles_law/database.ts +++ b/src/stories/hubbles_law/database.ts @@ -431,13 +431,21 @@ export async function _getStageThreeStudentData(studentID: number, classID: numb const MINIMAL_MEASUREMENT_FIELDS = ["student_id", "galaxy_id", "velocity_value", "est_dist_value", "class_id"]; -export async function getAllHubbleMeasurements(before: Date | null = null, minimal=false, classID: number | null = null): Promise { +export async function getAllHubbleMeasurements(before: Date | null = null, + minimal=false, + classID: number | null = null, + excludeWithNull=true): Promise { const whereOptions: WhereOptions = [ { "$student.IgnoreStudents.student_id$": null } ]; if (before !== null) { whereOptions.push({ last_modified: { [Op.lt]: before } }); } + if (excludeWithNull) { + for (const [key, condition] of Object.entries(EXCLUDE_MEASUREMENTS_WITH_NULL_CONDITION)) { + whereOptions.push({ [key]: condition }); + } + } const classesWhere: WhereOptions = []; if (classID !== null) { const classIDs = await getMergedIDsForClass(classID, true);