pub fn crev_crate_versions(crate_name: &str) -> anyhow::Result<Vec<VersionItemData>> {
    // region: vec_of_reviews for this crate
    let new_filter = ReviewFilterData {
        crate_name: crate_name.to_string(),
        crate_version: None,
        old_crate_version: None,
    };
    // my reviews from crev
    let vec_of_reviews = crev_list_my_reviews(&Some(new_filter))?;

    // endregion: vec_of_reviews for this crate

    // yanked from db_yanked
    let yanked_one_crate = crate::db_sled_mod::db_yanked_mod::all_versions_for_crate(crate_name)?;

    // versions from db_version
    let mut vec_of_version = vec![];
    for version_for_db in crate::db_sled_mod::db_version_mod::all_versions_for_crate(crate_name)? {
        let (_io_crate_name, io_crate_version) = split_crate_version(version_for_db.crate_name_version.as_str());

        // is_src_cache (if path exists in cargo registry src)
        let path_dir = crate::cargo_registry_mod::cargo_registry_src_dir_for_crate(crate_name, &io_crate_version)?;
        let is_src_cached = Some(path_dir.exists());

        let yanked = yanked_one_crate.iter().any(|s| s.crate_name_version == version_for_db.crate_name_version);

        // my_review
        let mut my_review = None;
        for review in vec_of_reviews.iter() {
            if review.package.name == crate_name && review.package.version.as_str() == &io_crate_version {
                my_review = Some(ReviewItemData {
                    crate_name: review.package.name.clone(),
                    crate_version: review.package.version.clone(),
                    date: review.date.clone(),
                    thoroughness: review.review.as_ref().context("review")?.thoroughness.to_string(),
                    understanding: review.review.as_ref().context("review")?.understanding.to_string(),
                    rating: rating_to_string(&review.review.as_ref().context("review")?.rating),
                    comment_md: review.comment.as_ref().unwrap_or(&String::new()).clone(),
                });
                break;
            }
        }

        // add to vector
        let version = VersionItemData {
            crate_name: crate_name.to_string(),
            crate_version: io_crate_version.to_string(),
            yanked,
            published_by_url: version_for_db.published_by_url.clone(),
            published_date: version_for_db.published_date.clone(),
            is_src_cached,
            my_review: my_review.clone(),
        };
        vec_of_version.push(version);
    }
    //write_versions_json(versions_json)?;
    Ok(vec_of_version)
}
/// get all versions for one crate
get all versions for one crate
get all versions for one crate
pub fn crev_crate_versions(crate_name: &str) -> anyhow::Result<Vec<VersionItemData>> {
    // region: vec_of_reviews for this crate
    let new_filter = ReviewFilterData {
        crate_name: crate_name.to_string(),
        crate_version: None,
        old_crate_version: None,
    };
    // my reviews from crev
    let vec_of_reviews = crev_list_my_reviews(&Some(new_filter))?;
    // endregion: vec_of_reviews for this crate
    // yanked from db_yanked
    let yanked_one_crate = crate::db_sled_mod::db_yanked_mod::all_versions_for_crate(crate_name)?;
    // versions from db_version
    let mut vec_of_version = vec![];
    for version_for_db in crate::db_sled_mod::db_version_mod::all_versions_for_crate(crate_name)? {
        let (_io_crate_name, io_crate_version) = split_crate_version(version_for_db.crate_name_version.as_str());
        // is_src_cache (if path exists in cargo registry src)
        let path_dir = crate::cargo_registry_mod::cargo_registry_src_dir_for_crate(crate_name, &io_crate_version)?;
        let is_src_cached = Some(path_dir.exists());
        let yanked = yanked_one_crate.iter().any(|s| s.crate_name_version == version_for_db.crate_name_version);
        // my_review
        let mut my_review = None;
        for review in vec_of_reviews.iter() {
            if review.package.name == crate_name && review.package.version.as_str() == &io_crate_version {
                my_review = Some(ReviewItemData {
                    crate_name: review.package.name.clone(),
                    crate_version: review.package.version.clone(),
                    date: review.date.clone(),
                    thoroughness: review.review.as_ref().context("review")?.thoroughness.to_string(),
                    understanding: review.review.as_ref().context("review")?.understanding.to_string(),
                    rating: rating_to_string(&review.review.as_ref().context("review")?.rating),
                    comment_md: review.comment.as_ref().unwrap_or(&String::new()).clone(),
                });
                break;
            }
        }
        // add to vector
        let version = VersionItemData {
            crate_name: crate_name.to_string(),
            crate_version: io_crate_version.to_string(),
            yanked,
            published_by_url: version_for_db.published_by_url.clone(),
            published_date: version_for_db.published_date.clone(),
            is_src_cached,
            my_review: my_review.clone(),
        };
        vec_of_version.push(version);
    }
    //write_versions_json(versions_json)?;
    Ok(vec_of_version)
}
pub fn crev_crate_versions ( crate_name : & str ) -> anyhow :: Result < Vec < VersionItemData > > { // region: vec_of_reviews for this crate let new_filter = ReviewFilterData { crate_name : crate_name . to_string ( ) , crate_version : None , old_crate_version : None , } ; // my reviews from crev let vec_of_reviews = crev_list_my_reviews ( & Some ( new_filter ) ) ? ; // endregion: vec_of_reviews for this crate // yanked from db_yanked let yanked_one_crate = crate :: db_sled_mod :: db_yanked_mod :: all_versions_for_crate ( crate_name ) ? ; // versions from db_version let mut vec_of_version = vec ! [ ] ; for version_for_db in crate :: db_sled_mod :: db_version_mod :: all_versions_for_crate ( crate_name ) ? { let ( _io_crate_name , io_crate_version ) = split_crate_version ( version_for_db . crate_name_version . as_str ( ) ) ; // is_src_cache (if path exists in cargo registry src) let path_dir = crate :: cargo_registry_mod :: cargo_registry_src_dir_for_crate ( crate_name , & io_crate_version ) ? ; let is_src_cached = Some ( path_dir . exists ( ) ) ; let yanked = yanked_one_crate . iter ( ) . any ( | s | s . crate_name_version == version_for_db . crate_name_version ) ; // my_review let mut my_review = None ; for review in vec_of_reviews . iter ( ) { if review . package . name == crate_name && review . package . version . as_str ( ) == & io_crate_version { my_review = Some ( ReviewItemData { crate_name : review . package . name . clone ( ) , crate_version : review . package . version . clone ( ) , date : review . date . clone ( ) , thoroughness : review . review . as_ref ( ) . context ( " " ) ? . thoroughness . to_string ( ) , understanding : review . review . as_ref ( ) . context ( " " ) ? . understanding . to_string ( ) , rating : rating_to_string ( & review . review . as_ref ( ) . context ( " " ) ? . rating ) , comment_md : review . comment . as_ref ( ) . unwrap_or ( & String :: new ( ) ) . clone ( ) , } ) ; break ; } } // add to vector let version = VersionItemData { crate_name : crate_name . to_string ( ) , crate_version : io_crate_version . to_string ( ) , yanked , published_by_url : version_for_db . published_by_url . clone ( ) , published_date : version_for_db . published_date . clone ( ) , is_src_cached , my_review : my_review . clone ( ) , } ; vec_of_version . push ( version ) ; } //write_versions_json(versions_json)?; Ok ( vec_of_version ) }
get all versions for one crate
get all versions for one crate
crate_name
&str