mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-19 07:29:46 +02:00
working datetime impl
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
use chrono::Utc;
|
||||
use futures::Stream;
|
||||
use std::{
|
||||
sync::Arc,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use surrealdb::{opt::PatchOp, Error, Notification};
|
||||
use tracing::{error, info};
|
||||
|
||||
@@ -74,17 +71,11 @@ impl JobQueue {
|
||||
id: &str,
|
||||
status: JobStatus,
|
||||
) -> Result<Option<Job>, AppError> {
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis()
|
||||
.to_string();
|
||||
|
||||
let job: Option<Job> = self
|
||||
.db
|
||||
.update((Job::table_name(), id))
|
||||
.patch(PatchOp::replace("/status", status))
|
||||
.patch(PatchOp::replace("/updated_at", now))
|
||||
.patch(PatchOp::replace("/updated_at", Utc::now()))
|
||||
.await?;
|
||||
|
||||
Ok(job)
|
||||
@@ -98,11 +89,9 @@ impl JobQueue {
|
||||
}
|
||||
|
||||
/// Get unfinished jobs, ie newly created and in progress up two times
|
||||
// pub async fn get_unfinished_jobs(&self) -> Result<Vec<Job>, AppError> {
|
||||
pub async fn get_unfinished_jobs(&self) -> Result<(), AppError> {
|
||||
pub async fn get_unfinished_jobs(&self) -> Result<Vec<Job>, AppError> {
|
||||
info!("Getting unfinished jobs");
|
||||
// let jobs: Vec<Job> = self
|
||||
let jobs = self
|
||||
let jobs: Vec<Job> = self
|
||||
.db
|
||||
.query(
|
||||
"SELECT * FROM type::table($table)
|
||||
@@ -116,14 +105,10 @@ impl JobQueue {
|
||||
)
|
||||
.bind(("table", Job::table_name()))
|
||||
.bind(("max_attempts", MAX_ATTEMPTS))
|
||||
.await?;
|
||||
// .take(0)?;
|
||||
.await?
|
||||
.take(0)?;
|
||||
|
||||
info!("{:?}", jobs);
|
||||
// println!("Unfinished jobs found: {}", jobs.len());
|
||||
|
||||
Ok(())
|
||||
// Ok(jobs)
|
||||
Ok(jobs)
|
||||
}
|
||||
|
||||
// Method to process a single job
|
||||
|
||||
Reference in New Issue
Block a user