Skip to content

Commit 6ecf0df

Browse files
committed
update data; use json routes
1 parent 48b2132 commit 6ecf0df

File tree

172 files changed

+856
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+856
-424
lines changed

data-lib/src/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
version::Version,
99
};
1010

11-
pub const LOC_EXCLUDED: [&'static str; 24] = [
11+
pub const LOC_EXCLUDED: &[&str] = &[
1212
"JSON",
1313
"SVG",
1414
"XML",
@@ -35,6 +35,11 @@ pub const LOC_EXCLUDED: [&'static str; 24] = [
3535
"TeX",
3636
];
3737

38+
pub const FILE_EXT_INCLUDED: &[&str] = &[
39+
"ts", "tsx", "mts", "cts", "js", "jsx", "mjs", "cjs", "css", "svelte", "vue", "scss", "sass",
40+
"py", "rs", "java", "kt", "rb", "c", "cpp", "h", "hpp",
41+
];
42+
3843
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
3944
pub struct EntryChange {
4045
pub property: String,

data-lib/src/plugin/data_array.rs

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::ops::Index;
22

3-
use chumsky::container::Seq;
43
use wasm_bindgen::prelude::wasm_bindgen;
54

65
use crate::{
76
common::{
8-
CountMonthlyDataPoint, DownloadDataPoint, HallOfFameDataPoint,
7+
CountMonthlyDataPoint, DownloadDataPoint, FILE_EXT_INCLUDED, HallOfFameDataPoint,
98
InactivityByReleaseDataPoint, IndividualDownloadDataPoint, LOC_EXCLUDED, OverviewDataPoint,
109
RemovedByReleaseDataPoint, increment_named_data_points, to_percentage,
1110
},
@@ -689,6 +688,76 @@ impl PluginDataArrayView {
689688
.filter(|point| !LOC_EXCLUDED.contains(&point.name.as_str()))
690689
.collect()
691690
}
691+
692+
pub fn file_count_by_extension(&self, data: &PluginDataArray) -> Vec<NamedDataPoint> {
693+
let mut points = Vec::new();
694+
695+
self.data.iter().for_each(|&index| {
696+
let plugin_data = &data[index];
697+
let Some(repo_data) = plugin_data.repo_data() else {
698+
return;
699+
};
700+
701+
repo_data.file_type_counts.iter().for_each(|(ext, count)| {
702+
increment_named_data_points(&mut points, ext, *count as f64);
703+
});
704+
});
705+
706+
points
707+
.into_iter()
708+
.filter(|point| FILE_EXT_INCLUDED.contains(&point.name.to_lowercase().as_str()))
709+
.collect()
710+
}
711+
712+
pub fn lines_of_code_distribution(&self, data: &PluginDataArray) -> Vec<u32> {
713+
let mut tmp: Vec<_> = self
714+
.data
715+
.iter()
716+
.map(|&index| {
717+
let plugin_data = &data[index];
718+
719+
let Some(repo_data) = plugin_data.repo_data() else {
720+
return 0;
721+
};
722+
723+
repo_data
724+
.lines_of_code
725+
.iter()
726+
.filter(|(lang, _)| !LOC_EXCLUDED.contains(&lang.as_str()))
727+
.map(|(_, loc)| loc)
728+
.sum::<usize>() as u32
729+
})
730+
.filter(|&count| count > 0)
731+
.collect();
732+
733+
tmp.sort_by(|a, b| b.cmp(a));
734+
tmp
735+
}
736+
737+
pub fn file_count_distribution(&self, data: &PluginDataArray) -> Vec<u32> {
738+
let mut tmp: Vec<_> = self
739+
.data
740+
.iter()
741+
.map(|&index| {
742+
let plugin_data = &data[index];
743+
744+
let Some(repo_data) = plugin_data.repo_data() else {
745+
return 0;
746+
};
747+
748+
repo_data
749+
.file_type_counts
750+
.iter()
751+
.filter(|(ext, _)| FILE_EXT_INCLUDED.contains(&ext.to_lowercase().as_str()))
752+
.map(|(_, count)| count)
753+
.sum::<usize>() as u32
754+
})
755+
.filter(|&count| count > 0)
756+
.collect();
757+
758+
tmp.sort_by(|a, b| b.cmp(a));
759+
tmp
760+
}
692761
}
693762

694763
#[wasm_bindgen]

data-lib/src/plugin/packages.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ impl PackageManager {
5252
}
5353

5454
pub fn iter_variants() -> impl Iterator<Item = PackageManager> {
55-
PackageManager::variants()
56-
.into_iter()
57-
.cloned()
55+
PackageManager::variants().into_iter().cloned()
5856
}
5957

6058
pub const fn variants() -> &'static [PackageManager] {

data/out/licenses.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -985,25 +985,25 @@
985985
}
986986
],
987987
"permissions": [
988-
"modifications",
988+
"distribution",
989989
"private-use",
990+
"modifications",
990991
"patent-use",
991-
"commercial-use",
992-
"distribution"
992+
"commercial-use"
993993
],
994994
"conditions": [
995-
"disclose-source",
996-
"network-use-disclose",
997-
"same-license",
995+
"include-copyright--source",
996+
"same-license--file",
997+
"include-copyright",
998998
"same-license--library",
999999
"document-changes",
1000-
"include-copyright",
1001-
"include-copyright--source",
1002-
"same-license--file"
1000+
"disclose-source",
1001+
"same-license",
1002+
"network-use-disclose"
10031003
],
10041004
"limitations": [
1005-
"liability",
10061005
"warranty",
1006+
"liability",
10071007
"trademark-use",
10081008
"patent-use"
10091009
],

data/out/plugin-data/chunk_0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/out/plugin-data/chunk_1.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/out/plugin-data/chunk_10.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/out/plugin-data/chunk_11.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/out/plugin-data/chunk_12.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/out/plugin-data/chunk_13.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)