pub async fn sync_links(db: &Database, links: BTreeMap<String, LinkConfig>, huddles: BTreeMap<String, HuddleConfig>) {
    // Get all the links.
    let db_links = Links::get_from_db(db);
    // Create a BTreeMap
    let mut link_map: BTreeMap<String, Link> = Default::default();
    for u in db_links {
        link_map.insert(u.name.to_string(), u);
    }
    // Sync links.
    for (name, mut link) in links {
        link.name = name.to_string();
        link.short_link = format!("https://{}.corp.{}", name, DOMAIN);

        link.upsert(db).await;

        // Remove the link from the BTreeMap.
        link_map.remove(&link.name);
    }
    for (slug, huddle) in huddles {
        // Create the link for the workspace.
        let mut link = LinkConfig {
            name: format!("{}-huddle", slug),
            description: huddle.description.to_string(),
            link: huddle.link_to_airtable_workspace.to_string(),
            aliases: vec![format!("airtable-{}-huddle", slug)],
            short_link: format!("https://{}-huddle.corp.{}", slug, DOMAIN),
        };

        link.upsert(db).await;

        // Remove the link from the BTreeMap.
        link_map.remove(&link.name);

        // Update the link for the form.
        link.name = format!("{}-huddle-form", slug);
        link.link = huddle.link_to_airtable_form.to_string();
        link.aliases = vec![format!("airtable-{}-huddle-form", slug)];
        link.short_link = format!("https://{}-huddle-form.corp.{}", slug, DOMAIN);
        link.description = format!("Form for submitting topics to the {}", huddle.description.to_lowercase());

        link.upsert(db).await;

        // Remove the link from the BTreeMap.
        link_map.remove(&link.name);
    }
    // Remove any links that should no longer be in the database.
    // This is found by the remaining links that are in the map since we removed
    // the existing repos from the map above.
    for (_, link) in link_map {
        link.delete(db).await;
    }
    println!("updated configs links in the database");

    // Update links in airtable.
    Links::get_from_db(db).update_airtable().await;
}
/// Sync our links with our database and then update Airtable from the database.
Sync our links with our database and then update Airtable from the database.
Sync our links with our database and then update Airtable from the database .
pub async fn sync_links(db: &Database, links: BTreeMap<String, LinkConfig>, huddles: BTreeMap<String, HuddleConfig>) {
    // Get all the links.
    let db_links = Links::get_from_db(db);
    // Create a BTreeMap
    let mut link_map: BTreeMap<String, Link> = Default::default();
    for u in db_links {
        link_map.insert(u.name.to_string(), u);
    }
    // Sync links.
    for (name, mut link) in links {
        link.name = name.to_string();
        link.short_link = format!("https://{}.corp.{}", name, DOMAIN);
        link.upsert(db).await;
        // Remove the link from the BTreeMap.
        link_map.remove(&link.name);
    }
    for (slug, huddle) in huddles {
        // Create the link for the workspace.
        let mut link = LinkConfig {
            name: format!("{}-huddle", slug),
            description: huddle.description.to_string(),
            link: huddle.link_to_airtable_workspace.to_string(),
            aliases: vec![format!("airtable-{}-huddle", slug)],
            short_link: format!("https://{}-huddle.corp.{}", slug, DOMAIN),
        };
        link.upsert(db).await;
        // Remove the link from the BTreeMap.
        link_map.remove(&link.name);
        // Update the link for the form.
        link.name = format!("{}-huddle-form", slug);
        link.link = huddle.link_to_airtable_form.to_string();
        link.aliases = vec![format!("airtable-{}-huddle-form", slug)];
        link.short_link = format!("https://{}-huddle-form.corp.{}", slug, DOMAIN);
        link.description = format!("Form for submitting topics to the {}", huddle.description.to_lowercase());
        link.upsert(db).await;
        // Remove the link from the BTreeMap.
        link_map.remove(&link.name);
    }
    // Remove any links that should no longer be in the database.
    // This is found by the remaining links that are in the map since we removed
    // the existing repos from the map above.
    for (_, link) in link_map {
        link.delete(db).await;
    }
    println!("updated configs links in the database");
    // Update links in airtable.
    Links::get_from_db(db).update_airtable().await;
}
pub async fn sync_links ( db : & Database , links : BTreeMap < String , LinkConfig > , huddles : BTreeMap < String , HuddleConfig > ) { // Get all the links. let db_links = Links :: get_from_db ( db ) ; // Create a BTreeMap let mut link_map : BTreeMap < String , Link > = Default :: default ( ) ; for u in db_links { link_map . insert ( u . name . to_string ( ) , u ) ; } // Sync links. for ( name , mut link ) in links { link . name = name . to_string ( ) ; link . short_link = format ! ( " " name DOMAIN ) ; link . upsert ( db ) . await ; // Remove the link from the BTreeMap. link_map . remove ( & link . name ) ; } for ( slug , huddle ) in huddles { // Create the link for the workspace. let mut link = LinkConfig { name : format ! ( " " slug ) , description : huddle . description . to_string ( ) , link : huddle . link_to_airtable_workspace . to_string ( ) , aliases : vec ! [ format ( " " slug ) ] , short_link : format ! ( " " slug DOMAIN ) , } ; link . upsert ( db ) . await ; // Remove the link from the BTreeMap. link_map . remove ( & link . name ) ; // Update the link for the form. link . name = format ! ( " " slug ) ; link . link = huddle . link_to_airtable_form . to_string ( ) ; link . aliases = vec ! [ format ( " " slug ) ] ; link . short_link = format ! ( " " slug DOMAIN ) ; link . description = format ! ( " " huddle description to_lowercase ( ) ) ; link . upsert ( db ) . await ; // Remove the link from the BTreeMap. link_map . remove ( & link . name ) ; } // Remove any links that should no longer be in the database. // This is found by the remaining links that are in the map since we removed // the existing repos from the map above. for ( _ , link ) in link_map { link . delete ( db ) . await ; } println ! ( " " ) ; // Update links in airtable. Links :: get_from_db ( db ) . update_airtable ( ) . await ; }
Sync our links with our database and then update Airtable from the database.
Sync our links with our database and then update Airtable from the database .
db
&Database
links
BTreeMap<String, LinkConfig>
huddles
BTreeMap<String, HuddleConfig>
db
&Database
links
BTreeMap<String, LinkConfig>
huddles
BTreeMap<String, HuddleConfig>