takes into account language.children
@@ -168,11 +168,26 @@ impl Language {
if sum_language_code == 0 {
None
} else {
- for (k, v) in languages.iter() {
- let code = v.code as f64;
+ for (language_type, language) in languages.iter() {
+ let mut code = language.code as usize;
+
+ let has_children = !language.children.is_empty();
+
+ if has_children {
+ for reports in language.children.values() {
+ for stats in reports.iter().map(|r| r.stats.summarise()) {
+ code += stats.code;
+ }
+ }
+ }
+
+ if code == 0 {
+ continue;
+ }
+
stats.insert(
- Language::from(*k),
- (code / sum_language_code as f64) * 100.00,
+ Language::from(*language_type),
+ (code as f64 / sum_language_code as f64) * 100.00,
);
}
Some(stats)
