Use prefixed numbers for badges
This commit is contained in:
parent
1f807a14fb
commit
6b68d291c8
12
src/main.rs
12
src/main.rs
@ -25,6 +25,7 @@ use badge::{Badge, BadgeOptions};
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::{unsync::mpsc, Stream};
|
use futures::{unsync::mpsc, Stream};
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
|
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
||||||
use std::{
|
use std::{
|
||||||
fs::create_dir_all,
|
fs::create_dir_all,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@ -188,10 +189,14 @@ fn calculate_hoc<T: Service>(
|
|||||||
}
|
}
|
||||||
pull(&path)?;
|
pull(&path)?;
|
||||||
let (hoc, _) = hoc(&service_path, &state.repos, &state.cache)?;
|
let (hoc, _) = hoc(&service_path, &state.repos, &state.cache)?;
|
||||||
|
let hoc = match NumberPrefix::decimal(hoc as f64) {
|
||||||
|
Standalone(hoc) => hoc.to_string(),
|
||||||
|
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
||||||
|
};
|
||||||
let badge_opt = BadgeOptions {
|
let badge_opt = BadgeOptions {
|
||||||
subject: "Hits-of-Code".to_string(),
|
subject: "Hits-of-Code".to_string(),
|
||||||
color: "#007ec6".to_string(),
|
color: "#007ec6".to_string(),
|
||||||
status: hoc.to_string(),
|
status: hoc,
|
||||||
};
|
};
|
||||||
let badge = Badge::new(badge_opt)?;
|
let badge = Badge::new(badge_opt)?;
|
||||||
|
|
||||||
@ -231,6 +236,10 @@ fn overview<T: Service>(
|
|||||||
}
|
}
|
||||||
pull(&path)?;
|
pull(&path)?;
|
||||||
let (hoc, head) = hoc(&service_path, &state.repos, &state.cache)?;
|
let (hoc, head) = hoc(&service_path, &state.repos, &state.cache)?;
|
||||||
|
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||||
|
Standalone(hoc) => hoc.to_string(),
|
||||||
|
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
||||||
|
};
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let req_path = format!("{}/{}/{}", T::url_path(), data.0, data.1);
|
let req_path = format!("{}/{}/{}", T::url_path(), data.0, data.1);
|
||||||
templates::overview(
|
templates::overview(
|
||||||
@ -240,6 +249,7 @@ fn overview<T: Service>(
|
|||||||
&req_path,
|
&req_path,
|
||||||
&url,
|
&url,
|
||||||
hoc,
|
hoc,
|
||||||
|
&hoc_pretty,
|
||||||
&head,
|
&head,
|
||||||
&T::commit_url(&repo, &head),
|
&T::commit_url(&repo, &head),
|
||||||
)?;
|
)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user