mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
refactor(send): apply ponytail audit cuts 2, 4, 6
- updated_sequence_task: clone the Task and mutate the two fields instead of rebuilding all 12 by hand (-22 lines; new fields no longer need a sync here) - unify unix_now with db::now_f64 (unix_now() = now_f64() as i64), moved to db.rs next to its clock source - classify_to_send_error takes the MediaFetchFailure label, folding the duplicated inline match in send_batch_via_upload (-8 lines)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
//! Per-chat state with SQLite persistence (table `chat_state` in
|
||||
//! `data/task_queue.db`, shared with the task queue).
|
||||
|
||||
use crate::db::unix_now;
|
||||
use parking_lot::Mutex;
|
||||
use rusqlite::params;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
|
||||
pub struct ChatData {
|
||||
@@ -40,13 +41,6 @@ pub struct ChatStore {
|
||||
pool: Arc<crate::db::DbPool>,
|
||||
}
|
||||
|
||||
pub fn unix_now() -> i64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|d| d.as_secs() as i64)
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
impl ChatStore {
|
||||
/// Wraps the shared DB pool (schema initialized once by
|
||||
/// [`crate::db::open_store`]; the `chat_state` table lives in the merged
|
||||
|
||||
Reference in New Issue
Block a user