From c5e1713ef404dbd1d921c17f6b6f2f911e0324af Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Sun, 14 Sep 2025 00:04:30 -0400 Subject: [PATCH] Asfd --- Cargo.lock | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 ++ src/main.rs | 6 +++-- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 234f4f7..98dc080 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,12 +154,24 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + [[package]] name = "find-msvc-tools" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" + [[package]] name = "heck" version = "0.5.0" @@ -190,12 +202,28 @@ dependencies = [ "cc", ] +[[package]] +name = "indexmap" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + [[package]] name = "js-sys" version = "0.3.78" @@ -263,6 +291,45 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "shlex" version = "1.3.0" @@ -292,6 +359,12 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "utf8parse" version = "0.2.2" @@ -304,6 +377,8 @@ version = "0.1.0" dependencies = [ "chrono", "clap", + "serde", + "serde_yaml", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0b6bc36..6f53b9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,5 @@ edition = "2024" [dependencies] clap = { version = "4.5.47", features = ["derive"] } chrono = "0.4" +serde_yaml = "0.9.34" +serde = {version = "1.0.219", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index 44c2140..a55b0a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,6 +94,7 @@ fn update_streak(daily_filepath: &str, file: &mut File) { // Get filepath from yesterday. If does not exist, return 0. let mut streak: u32 = 0; let yesterday_filepath = get_yesterday_filepath(); + let today = Local::now(); if let Err(e) = yesterday_filepath { let today_metadata = DailyPostMetadata { @@ -105,8 +106,9 @@ fn update_streak(daily_filepath: &str, file: &mut File) { return (); } - let filepath = yesterday_filepath.unwrap(); - let metadata: Result = read_daily_post_metadata(&filepath); + let filename = yesterday_filepath.unwrap(); + let fp = format!("{}/{}/{}", &daily_filepath, today.year(), filename); + let metadata: Result = read_daily_post_metadata(&fp); // Get metadata from yesterday's post. If metadata does not exist, return 1. if let Err(e) = metadata {