From c135edc2a105961fdc13461f37a8989353246cdc Mon Sep 17 00:00:00 2001 From: Sam Rijs Date: Sun, 11 Feb 2018 19:09:49 +1100 Subject: [PATCH] blacklist non-compatible popular repos --- src/engine/mod.rs | 19 ++++++++++++++++++- src/models/repo.rs | 8 ++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/engine/mod.rs b/src/engine/mod.rs index 2bd682d..0ed6c4a 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::Duration; @@ -59,7 +60,11 @@ impl Engine { impl Future, Error=Error> { self.get_popular_repos.call(()) - .from_err().map(|repos| repos.clone()) + .from_err().map(|repos| { + repos.iter() + .filter(|repo| !POPULAR_REPOS_BLACKLIST.contains(&repo.path)) + .cloned().collect() + }) } pub fn analyze_dependencies(&self, repo_path: RepoPath) -> @@ -96,3 +101,15 @@ impl Engine { retrieve_file_at_path(self.client.clone(), &repo_path, &path.as_ref().join("Cargo.toml")).from_err() } } + +lazy_static! { + static ref POPULAR_REPOS_BLACKLIST: HashSet = { + vec![ + RepoPath::from_parts("github", "rust-lang", "rust"), + RepoPath::from_parts("github", "google", "xi-editor"), + RepoPath::from_parts("github", "lk-geimfari", "awesomo"), + RepoPath::from_parts("github", "redox-os", "tfs"), + RepoPath::from_parts("github", "carols10cents", "rustlings") + ].into_iter().collect::, _>>().unwrap() + }; +} diff --git a/src/models/repo.rs b/src/models/repo.rs index 41df4f7..d70a1c1 100644 --- a/src/models/repo.rs +++ b/src/models/repo.rs @@ -8,7 +8,7 @@ pub struct Repository { pub description: String } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct RepoPath { pub site: RepoSite, pub qual: RepoQualifier, @@ -25,7 +25,7 @@ impl RepoPath { } } -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] pub enum RepoSite { Github } @@ -57,7 +57,7 @@ impl AsRef for RepoSite { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct RepoQualifier(String); impl FromStr for RepoQualifier { @@ -79,7 +79,7 @@ impl AsRef for RepoQualifier { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct RepoName(String); impl FromStr for RepoName {