Skip to content

Commit

Permalink
Fix bna-save-results (#24)
Browse files Browse the repository at this point in the history
Fixes the lambda function to ensure the pipeline details, get
updated correctly.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho authored Dec 9, 2024
1 parent cf6eb20 commit 6527eb5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ aws-sdk-s3 = "1.65.0"
aws-sdk-sqs = "1.50.0"
aws-smithy-types-convert = "0.60.8"
axum = "0.7.7"
bnaclient = { git = "https://github.com/PeopleForBikes/bna-api", rev = "790006d" }
bnaclient = { git = "https://github.com/PeopleForBikes/bna-api", rev = "b662dc9" }
bnacore = { git = "https://github.com/PeopleForBikes/brokenspoke", rev = "c20ec31" }
chrono = "0.4.19"
chrono = "0.4.39"
clap = "4.5.20"
color-eyre = "0.6.2"
csv = "1.3.1"
Expand Down Expand Up @@ -45,7 +45,7 @@ simple-error = "0.3.0"
slug = "0.1.6"
svg2pdf = "0.12.0"
test-log = "0.2.16"
thiserror = "2.0.5"
thiserror = "2.0.6"
tokio = "1.42.0"
tower = "0.5.1"
tower-cookies = "0.10.0"
Expand Down
25 changes: 23 additions & 2 deletions lambdas/src/bna-save-results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ async fn function_handler(event: LambdaEvent<TaskInput>) -> Result<(), Error> {

// Compute the price.
let cost = fargate_time.cost(FARGATE_COST_PER_SEC);
info!(cost = ?cost);

// Update the pipeline status.
info!("updating pipeline...");
let start_time = started_at.to_chrono_utc().ok();
let end_time = stopped_at.to_chrono_utc().ok();
client_authd
let _r = client_authd
.patch_analysis()
.analysis_id(StateMachineId(state_machine_id))
.body(
Expand Down Expand Up @@ -515,7 +516,7 @@ mod tests {
// let get_cities_url = format!("{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1TlPYndXhuZoTCpR07wJhqDZQ"),
// access_token: String::from(""),
// expires_in: 3600,
// token_type: String::from("Bearer"),
// };
Expand Down Expand Up @@ -598,6 +599,7 @@ mod tests {
.unwrap();

let fargate_time = FargateTime::new(started_at, stopped_at);
assert_eq!(fargate_time.elapsed(), 10);
assert_eq!(
fargate_time.cost(FARGATE_COST_PER_SEC),
dec!(0.0228333333333)
Expand Down Expand Up @@ -701,4 +703,23 @@ mod tests {
// let response = client.post_ratings().body(bna_post).send().await.unwrap();
// dbg!(response);
// }

// #[test(tokio::test)]
// async fn test_create_pipeline() {
// let client = bnaclient::Client::new("http://localhost:3000");
// let analysis_post_builder = AnalysisPost::builder()
// .state_machine_id(StateMachineId(uuid::Uuid::new_v4()))
// .start_time(Utc::now())
// .cost(Decimal::new(10345, 3).to_f64().expect("no overflow"))
// .step(Step::Setup);
// let analysis_post: AnalysisPost = analysis_post_builder.try_into().unwrap();
// println!("{}", serde_json::to_string(&analysis_post).unwrap());
// let r = client
// .post_ratings_analyses()
// .body(analysis_post)
// .send()
// .await
// .unwrap();
// dbg!(r);
// }
}

0 comments on commit 6527eb5

Please sign in to comment.