Skip to content

Commit

Permalink
Merge pull request #142 from samply/fix/aesthetics
Browse files Browse the repository at this point in the history
Fix/aesthetics
  • Loading branch information
enola-dkfz authored May 22, 2024
2 parents f73134e + d2f7e51 commit 2d977c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
16 changes: 3 additions & 13 deletions src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,17 @@ pub async fn post_exporter_query(body: &String, task_type: TaskType) -> Result<S
}

if task_type == TaskType::Status {
let value: Value = serde_json::from_str(
String::from_utf8(util::base64_decode(&body)?)
.map_err(|e| {
FocusError::DeserializationError(format!(
r#"Task body is not a valid string {}"#,
e
))
})?
.as_str(),
)
let value: Value = serde_json::from_slice(&(util::base64_decode(body))?)
.map_err(|e| {
FocusError::DeserializationError(format!(r#"Task body is not a valid JSON: {}"#, e))
})?;
let id = value["query-execution-id"].as_str();
if id.is_none() {
let Some(id) = id else {
return Err(FocusError::ParsingError(format!(
r#"Body does not contain the id of the query to check the status of: {}"#,
value
)));
}
let id: &str = id.unwrap(); //we already made sure that it is not None
};

let resp = CONFIG
.client
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ async fn process_task(
));
}
if metadata.project == "exporter" {
if metadata.task_type.is_none() {
return Err(FocusError::MissingExporterTaskType)
}
let Some(task_type) = metadata.task_type else {
return Err(FocusError::MissingExporterTaskType);
};
let body = &task.body;
return Ok(run_exporter_query(task, body, metadata.task_type.unwrap()).await)?; //we already made sure that it is not None
return Ok(run_exporter_query(task, body, task_type).await)?; //we already made sure that it is not None
}

if CONFIG.endpoint_type == EndpointType::Blaze {
Expand Down

0 comments on commit 2d977c3

Please sign in to comment.