`stat` handler
(&self)
| 9 | impl StatArgs { |
| 10 | /// `stat` handler |
| 11 | pub async fn run(&self) -> Result<(), crate::err::Error> { |
| 12 | use crate::{Cache, helper::Digit}; |
| 13 | |
| 14 | let cache = Cache::new()?; |
| 15 | let res = cache.get_problems()?; |
| 16 | |
| 17 | let mut easy: f64 = 0.00; |
| 18 | let mut easy_ac: f64 = 0.00; |
| 19 | let mut medium: f64 = 0.00; |
| 20 | let mut medium_ac: f64 = 0.00; |
| 21 | let mut hard: f64 = 0.00; |
| 22 | let mut hard_ac: f64 = 0.00; |
| 23 | |
| 24 | for i in res.into_iter() { |
| 25 | match i.level { |
| 26 | 1 => { |
| 27 | easy += 1.00; |
| 28 | if i.status == "ac" { |
| 29 | easy_ac += 1.00; |
| 30 | } |
| 31 | } |
| 32 | 2 => { |
| 33 | medium += 1.00; |
| 34 | if i.status == "ac" { |
| 35 | medium_ac += 1.00; |
| 36 | } |
| 37 | } |
| 38 | 3 => { |
| 39 | hard += 1.00; |
| 40 | if i.status == "ac" { |
| 41 | hard_ac += 1.00; |
| 42 | } |
| 43 | } |
| 44 | _ => {} |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // level: len = 8 |
| 49 | // count: len = 10 |
| 50 | // percent: len = 16 |
| 51 | // chart: len = 32 |
| 52 | // title |
| 53 | println!( |
| 54 | "\n{}", |
| 55 | " Level Count Percent Chart".bright_black() |
| 56 | ); |
| 57 | println!( |
| 58 | "{}", |
| 59 | " -----------------------------------------------------------------".bright_black() |
| 60 | ); |
| 61 | |
| 62 | // lines |
| 63 | for (i, l) in [(easy, easy_ac), (medium, medium_ac), (hard, hard_ac)] |
| 64 | .iter() |
| 65 | .enumerate() |
| 66 | { |
| 67 | match i { |
| 68 | 0 => { |
no test coverage detected