Skip to content

Commit

Permalink
more stats
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed May 7, 2024
1 parent 82c693e commit fd62e01
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
36 changes: 23 additions & 13 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,20 +1053,7 @@ pub fn generate_pages(
crates,
)?;

let crates_with_both_edition_and_rust_version = render_filtered_crates(
"crates-with-both-edition-and-rust-version",
"Crates with both edition and rust-version",
|krate| {
krate.cargo.package.edition.is_some() && krate.cargo.package.rust_dash_version.is_some()
},
crates,
)?;

let stats = HashMap::from([
(
"crates_with_both_edition_and_rust_version",
crates_with_both_edition_and_rust_version,
),
(
"crates_without_edition_or_rust_version",
crates_without_edition_or_rust_version,
Expand All @@ -1089,6 +1076,15 @@ pub fn generate_pages(
let mut stats2 = vec![];
// crate_details
let cases = vec![
(
"crates_with_both_edition_and_rust_version",
"crates-with-both-edition-and-rust-version",
"Crates with both edition and rust-version",
CrateFilter::new(|krate: &&Crate| {
krate.cargo.package.edition.is_some()
&& krate.cargo.package.rust_dash_version.is_some()
}),
),
(
"has_interesting_homepage",
"has-interesting-homepage",
Expand All @@ -1101,6 +1097,20 @@ pub fn generate_pages(
"Crates with Cargo.lock file",
CrateFilter::new(|krate: &&Crate| krate.crate_details.has_cargo_lock),
),
(
"crates_without_cargo_lock",
"crates-without-cargo-lock",
"Crates without Cargo.lock file",
CrateFilter::new(|krate: &&Crate| !krate.crate_details.has_cargo_lock),
),
(
"crates_without_cargo_lock_without_main_rs",
"crates-without-cargo-lock-without-main-rs",
"Crates without Cargo.lock and without src/main.rs file",
CrateFilter::new(|krate: &&Crate| {
!krate.crate_details.has_cargo_lock && !krate.crate_details.has_main_rs
}),
),
];
for case in cases {
let count = render_filtered_crates(case.1, case.2, case.3.func, crates)?;
Expand Down
5 changes: 0 additions & 5 deletions templates/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ <h1 class="title">Rust Digger Stats</h1>
<td>{{percentage.crates_without_edition_or_rust_version}}%</td>
</tr>

<tr>
<td><a href="/crates-with-both-edition-and-rust-version">Crates with both edition rust-version in the Cargo.toml</a></td>
<td>{{stats.crates_with_both_edition_and_rust_version | commafy}}</td>
<td>{{percentage.crates_with_both_edition_and_rust_version}}%</td>
</tr>

{% for stat in stats2 %}
<tr>
Expand Down

0 comments on commit fd62e01

Please sign in to comment.