do rfds in groups of three concurrently
@@ -1045,8 +1045,16 @@ pub async fn refresh_db_rfds(db: &Database, company: &Company) -> Result<()> {
let rfds = get_rfds_from_repo(&github, company).await?;
// Iterate over the rfds and update.
+ // We should do these concurrently, but limit it to maybe 3 at a time.
+ let mut i = 0;
+ let take = 3;
+ let mut skip = 0;
+ while i < rfds.clone().len() {
let tasks: Vec<_> = rfds
+ .clone()
.into_iter()
+ .skip(skip)
+ .take(take)
.map(|(_, mut rfd)| {
tokio::spawn(enclose! { (db, company, github) async move {
rfd.sync(&db, &company, &github).await
@@ -1063,6 +1071,10 @@ pub async fn refresh_db_rfds(db: &Database, company: &Company) -> Result<()> {
result?;
}
+ i += take;
+ skip += take;
+ }
+
// Update rfds in airtable.
RFDs::get_from_db(db, company.id).await?.update_airtable(db).await?;
