Skip to content

Commit

Permalink
πŸ› Add back reporting & anti-race waits
Browse files Browse the repository at this point in the history
  • Loading branch information
malted committed Sep 11, 2024
1 parent b019a44 commit f706ef6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "replit-takeout"
version = "1.7.11"
version = "1.7.13"
edition = "2021"
authors = ["Ben Dixon <malted@malted.dev>"]

Expand Down
4 changes: 2 additions & 2 deletions examples/full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ async fn main() -> Result<()> {
log::error!("Error with `{}`'s download: {err:#?}", user.fields.username);

user.fields.status = ProcessState::ErroredMain;
//arst airtable::update_records(vec![user.clone()]).await?;
airtable::update_records(vec![user.clone()]).await?;

// user.fields.failed_ids = errored.join(",");
user.fields.failed_ids = errored.join(",");

// send_email(
// &user.fields.email,
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ async fn airtable_loop() -> Result<()> {
error!("Error with `{}`'s download: {err:#?}", user.fields.username);

user.fields.status = ProcessState::ErroredMain;
//arst airtable::update_records(vec![user.clone()]).await?;

// user.fields.failed_ids = errored.join(",");
airtable::update_records(vec![user.clone()]).await?;
user.fields.failed_ids = errored.join(",");

// send_email(
// &user.fields.email,
Expand Down
14 changes: 7 additions & 7 deletions src/replit_graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl ProfileRepls {
) -> Result<()> {
synced_user.fields.status = ProcessState::CollectingRepls;
synced_user.fields.started_at = Some(chrono::offset::Utc::now());
//arst airtable::update_records(vec![synced_user.clone()]).await?;
airtable::update_records(vec![synced_user.clone()]).await?;

let client = create_client(token, None)?;

Expand Down Expand Up @@ -225,7 +225,7 @@ impl ProfileRepls {
}

synced_user.fields.status = ProcessState::NoRepls;
//arst airtable::update_records(vec![synced_user.clone()]).await?;
airtable::update_records(vec![synced_user.clone()]).await?;
return Ok(());
}

Expand Down Expand Up @@ -342,13 +342,13 @@ impl ProfileRepls {
);

synced_user.fields.repl_count += 1;
//arst airtable::update_records(vec![synced_user.clone()]).await?;
airtable::update_records(vec![synced_user.clone()]).await?;
progress.report(&current_user);
}

progress.completed = true;
progress.report(&current_user);
//arst airtable::update_records(vec![synced_user.clone()]).await?;
airtable::update_records(vec![synced_user.clone()]).await?;

let path = format!("repls/{}", current_user.username);
make_zip(path.clone(), format!("repls/{}.zip", current_user.username)).await?;
Expand All @@ -365,11 +365,11 @@ impl ProfileRepls {
let upload_result = r2::upload(upload_path.clone(), zip_path.clone()).await;
fs::remove_file(&zip_path).await?;
synced_user.fields.status = ProcessState::WaitingInR2;
//arst airtable::update_records(vec![synced_user.clone()]).await?;
airtable::update_records(vec![synced_user.clone()]).await?;

if let Err(upload_err) = upload_result {
synced_user.fields.status = ProcessState::ErroredR2;
//arst airtable::update_records(vec![synced_user.clone()]).await?;
airtable::update_records(vec![synced_user.clone()]).await?;
error!("Failed to upload {upload_path} to R2");
return Err(upload_err);
}
Expand Down Expand Up @@ -433,7 +433,7 @@ impl ProfileRepls {
synced_user.fields.failed_ids = errored.join(",");
}
synced_user.fields.finished_at = Some(chrono::offset::Utc::now());
//arst airtable::update_records(vec![synced_user]).await?;
airtable::update_records(vec![synced_user]).await?;

Ok(())
}
Expand Down

0 comments on commit f706ef6

Please sign in to comment.