Remove instance filtering/sorting

This commit is contained in:
Felix Ableitner 2021-03-11 12:22:28 +01:00
parent 71cdf40bae
commit f3876b4745

View file

@ -12,10 +12,9 @@ const START_INSTANCES: [&'static str; 1] = ["lemmy.ml"];
#[tokio::main] #[tokio::main]
pub async fn main() -> Result<(), Error> { pub async fn main() -> Result<(), Error> {
let start_instances = START_INSTANCES.iter().map(|s| s.to_string()).collect(); let start_instances = START_INSTANCES.iter().map(|s| s.to_string()).collect();
eprintln!("Crawling..."); eprintln!("Crawling...");
let instance_details = crawl(start_instances).await?; let instance_details = crawl(start_instances).await?;
let instance_details = cleanup(instance_details);
let total_stats = aggregate(instance_details); let total_stats = aggregate(instance_details);
println!("{}", serde_json::to_string(&total_stats)?); println!("{}", serde_json::to_string(&total_stats)?);
@ -47,16 +46,6 @@ fn aggregate(instance_details: Vec<InstanceDetails>) -> TotalStats {
} }
} }
fn cleanup(instance_details: Vec<InstanceDetails>) -> Vec<InstanceDetails> {
let mut instance_details: Vec<InstanceDetails> = instance_details
.iter()
.filter(|i| i.open_registrations)
.map(|i| i.to_owned())
.collect();
instance_details.sort_by(|a, b| b.users_active_halfyear.cmp(&a.users_active_halfyear));
instance_details
}
async fn crawl(start_instances: Vec<String>) -> Result<Vec<InstanceDetails>, Error> { async fn crawl(start_instances: Vec<String>) -> Result<Vec<InstanceDetails>, Error> {
let mut pending_instances = start_instances; let mut pending_instances = start_instances;
let mut instance_details = vec![]; let mut instance_details = vec![];