Compare commits
2 Commits
c3c95fb9e5
...
228f7129d1
Author | SHA1 | Date |
---|---|---|
Anna | 228f7129d1 | |
Anna | 63dbe9c20c |
|
@ -754,6 +754,16 @@ version = "0.2.8"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
||||
|
||||
[[package]]
|
||||
name = "libmimalloc-sys"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.26.0"
|
||||
|
@ -809,6 +819,15 @@ version = "2.6.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||
|
||||
[[package]]
|
||||
name = "mimalloc"
|
||||
version = "0.1.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c"
|
||||
dependencies = [
|
||||
"libmimalloc-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.17"
|
||||
|
@ -1217,6 +1236,7 @@ dependencies = [
|
|||
"axum",
|
||||
"blake3",
|
||||
"chrono",
|
||||
"mimalloc",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -10,6 +10,7 @@ anyhow = "1"
|
|||
axum = { version = "0.6", features = ["json"] }
|
||||
blake3 = { version = "1", features = ["traits-preview"] }
|
||||
chrono = { version = "0.4", features = ["serde"]}
|
||||
mimalloc = "0.1"
|
||||
rand = "0.8"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
|
|
@ -12,7 +12,7 @@ use axum::http::StatusCode;
|
|||
use axum::routing::{get, post};
|
||||
use axum::{Router, Json};
|
||||
use axum::extract::{State, Path};
|
||||
use chrono::{NaiveDate, Utc, TimeZone, Datelike, Duration};
|
||||
use chrono::{NaiveDate, Utc, Datelike, Duration};
|
||||
use rand::distributions::{Alphanumeric, DistString};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::PgPool;
|
||||
|
@ -24,6 +24,9 @@ use crate::auth::User;
|
|||
use crate::config::Config;
|
||||
use crate::question::{FullQuestion, BasicQuestion, Question};
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let config: Config = {
|
||||
|
@ -452,17 +455,6 @@ async fn stat_breakdown(
|
|||
match &stat {
|
||||
Breakdown::Age => {
|
||||
for rec in records {
|
||||
// let date = match NaiveDate::parse_from_str(&rec.key, "%Y-%m-%d")
|
||||
// .ok()
|
||||
// .and_then(|date| date.and_hms_opt(0, 0, 0))
|
||||
// .map(|date| Utc.from_utc_datetime(&date))
|
||||
// {
|
||||
// Some(d) => d,
|
||||
// None => continue,
|
||||
// };
|
||||
|
||||
// let age = question.publish_date - date;
|
||||
// let years = age.num_days() / 365;
|
||||
let years: u32 = match rec.key.parse() {
|
||||
Ok(y) => y,
|
||||
Err(_) => continue,
|
||||
|
@ -487,13 +479,8 @@ async fn stat_breakdown(
|
|||
}
|
||||
Breakdown::ZodiacSign => {
|
||||
for rec in records {
|
||||
let date = match NaiveDate::parse_from_str(&rec.key, "%Y-%m-%d")
|
||||
.ok()
|
||||
.and_then(|date| date.and_hms_opt(0, 0, 0))
|
||||
.map(|date| Utc.from_utc_datetime(&date))
|
||||
{
|
||||
Some(d) => d,
|
||||
None => continue,
|
||||
let Ok(date) = NaiveDate::parse_from_str(&rec.key, "%Y-%m-%d") else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let birthday = (date.month() * 100) + date.day();
|
||||
|
|
Loading…
Reference in New Issue