Skip to content

Commit

Permalink
Handle null values from database
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Apr 17, 2024
1 parent 56c7f5f commit 918b0a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 43 deletions.
5 changes: 2 additions & 3 deletions processed_data/src/graphql/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use models::{
auto_proc_scaling_statistics, data_collection_file_attachment, processing_job,
processing_job_parameter, sea_orm_active_enums::ScalingStatisticsType,
};
use sea_orm::FromQueryResult;

/// Represents processed image file stored in s3 bucket
#[derive(Clone, Debug, PartialEq, SimpleObject)]
Expand Down Expand Up @@ -337,7 +336,7 @@ pub struct AP {
/// An opaque unique identifier for the processing processing job
pub processing_job_id: Option<u32>,
/// An opaque unique identifier for the auto processing
pub auto_proc_id: u32,
pub auto_proc_id: Option<u32>,
/// Space group of the processing job
pub space_group: Option<String>,
/// Refined cell a in the auto processing job
Expand All @@ -353,5 +352,5 @@ pub struct AP {
/// Refined cell gamma in the auto processing job
pub refined_cell_gamma: Option<f32>,
/// An opaque unique identifier for the auto processing scaling
pub auto_proc_scaling_id: u32,
pub auto_proc_scaling_id: Option<u32>,
}
59 changes: 19 additions & 40 deletions processed_data/src/graphql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use models::{
processing_job_parameter,
};
use sea_orm::{
ColumnTrait, ConnectionTrait, DatabaseConnection, EntityTrait, FromQueryResult, QueryFilter,
Statement,
ColumnTrait, ConnectionTrait, DatabaseConnection, EntityTrait, QueryFilter, Statement,
};
use sea_query::{self, Asterisk, Expr};
use std::time::Duration;
Expand Down Expand Up @@ -267,44 +266,24 @@ impl Loader<u32> for AutoProcIntegrationDataLoader {
.await?
.into_iter()
.map(|record| AP {
auto_proc_integration_id: record
.try_get("", "autoProcIntegrationId")
.unwrap(),
data_collection_id: record
.try_get("", "dataCollectionId")
.unwrap(),
auto_proc_program_id: record
.try_get("", "autoProcProgramId")
.unwrap(),
refined_x_beam: record
.try_get("", "refinedXBeam")
.unwrap(),
refined_y_beam: record
.try_get("", "refinedYBeam")
.unwrap(),
processing_programs: record
.try_get("", "processingPrograms")
.unwrap(),
processing_status: record
.try_get("", "processingStatus")
.unwrap(),
processing_message: record
.try_get("", "processingMessage")
.unwrap(),
processing_job_id: record
.try_get("", "processingJobId")
.unwrap(),
auto_proc_id: record.try_get("", "autoProcId").unwrap(),
space_group: record.try_get("", "spaceGroup").unwrap(),
refined_cell_a: record.try_get("", "refinedCell_a").unwrap(),
refined_cell_b: record.try_get("", "refinedCell_b").unwrap(),
refined_cell_c: record.try_get("", "refinedCell_c").unwrap(),
refined_cell_alpha: record.try_get("", "refinedCell_alpha").unwrap(),
refined_cell_beta: record.try_get("", "refinedCell_beta").unwrap(),
refined_cell_gamma: record.try_get("", "refinedCell_gamma").unwrap(),
auto_proc_scaling_id: record
.try_get("", "autoProcScalingId")
.unwrap(),
auto_proc_integration_id: record.try_get("", "autoProcIntegrationId").unwrap(),
data_collection_id: record.try_get("", "dataCollectionId").unwrap(),
auto_proc_program_id: Some(record.try_get("", "autoProcProgramId").unwrap()),
refined_x_beam: Some(record.try_get("", "refinedXBeam").unwrap()),
refined_y_beam: Some(record.try_get("", "refinedYBeam").unwrap()),
processing_programs: Some(record.try_get("", "processingPrograms").unwrap()),
processing_status: Some(record.try_get("", "processingStatus").unwrap()),
processing_message: Some(record.try_get("", "processingMessage").unwrap()),
processing_job_id: Some(record.try_get("", "processingJobId").unwrap()),
auto_proc_id: Some(record.try_get("", "autoProcId").unwrap()),
space_group: Some(record.try_get("", "spaceGroup").unwrap()),
refined_cell_a: Some(record.try_get("", "refinedCell_a").unwrap()),
refined_cell_b: Some(record.try_get("", "refinedCell_b").unwrap()),
refined_cell_c: Some(record.try_get("", "refinedCell_c").unwrap()),
refined_cell_alpha: Some(record.try_get("", "refinedCell_alpha").unwrap()),
refined_cell_beta: Some(record.try_get("", "refinedCell_beta").unwrap()),
refined_cell_gamma: Some(record.try_get("", "refinedCell_gamma").unwrap()),
auto_proc_scaling_id: Some(record.try_get("", "autoProcScalingId").unwrap()),
})
.collect::<Vec<_>>();

Expand Down

0 comments on commit 918b0a7

Please sign in to comment.