Add million support
This commit is contained in:
parent
8509f6e22d
commit
528fe15819
@ -1,5 +1,5 @@
|
||||
// CRATES
|
||||
use crate::utils::{format_url, request, val, Comment, ErrorTemplate, Flair, Params, Post, format_num};
|
||||
use crate::utils::{format_num, format_url, request, val, Comment, ErrorTemplate, Flair, Params, Post};
|
||||
use actix_web::{get, http::StatusCode, web, HttpResponse, Result};
|
||||
use askama::Template;
|
||||
use chrono::{TimeZone, Utc};
|
||||
|
@ -1,5 +1,5 @@
|
||||
// CRATES
|
||||
use crate::utils::{fetch_posts, format_url, request, val, ErrorTemplate, Params, Post, Subreddit, format_num};
|
||||
use crate::utils::{fetch_posts, format_num, format_url, request, val, ErrorTemplate, Params, Post, Subreddit};
|
||||
use actix_web::{get, http::StatusCode, web, HttpResponse, Result};
|
||||
use askama::Template;
|
||||
use std::convert::TryInto;
|
||||
|
@ -88,7 +88,13 @@ pub async fn format_url(url: &str) -> String {
|
||||
}
|
||||
|
||||
pub fn format_num(num: i64) -> String {
|
||||
return if num > 1000 { format!("{}k", num / 1000) } else { num.to_string() };
|
||||
if num > 1000000 {
|
||||
format!("{}m", num / 1000000)
|
||||
} else if num > 1000 {
|
||||
format!("{}k", num / 1000)
|
||||
} else {
|
||||
num.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user