Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: created_at & updated_at (#5)

Kould95c6cbbf45dd
diff --git a/Cargo.toml b/Cargo.toml
index e27e50d8cf..0c881467a4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,7 @@ serde_json = "1.0"
tracing-subscriber = "0.3.18"
dotenvy = "0.15.7"
listenfd = "1.0.1"
+chrono = "0.4.31"
migration = { path = "./migration" }
[[bin]]
diff --git a/src/api/tag.rs b/src/api/tag.rs
index 3af8a65a85..b902f3d3a3 100644
--- a/src/api/tag.rs
+++ b/src/api/tag.rs
@@ -11,7 +11,7 @@ async fn create(model: web::Json<tag_info::Model>, data: web::Data<AppState>) ->
let model = Mutation::create_tag(&data.conn, model.into_inner()).await.unwrap();
let mut result = HashMap::new();
- result.insert("tid", model.uid.unwrap());
+ result.insert("tid", model.tid.unwrap());
let json_response = JsonResponse {
code: 200,
diff --git a/src/entity/dialog_info.rs b/src/entity/dialog_info.rs
index d0c49359b4..a97999b2ec 100644
--- a/src/entity/dialog_info.rs
+++ b/src/entity/dialog_info.rs
@@ -11,7 +11,9 @@ pub struct Model {
pub dialog_name: String,
pub history: String,
+ #[serde(skip_deserializing)]
pub created_at: Date,
+ #[serde(skip_deserializing)]
pub updated_at: Date,
}
diff --git a/src/entity/doc_info.rs b/src/entity/doc_info.rs
index 4e5641b204..0f39a8d69b 100644
--- a/src/entity/doc_info.rs
+++ b/src/entity/doc_info.rs
@@ -14,10 +14,10 @@ pub struct Model {
pub r#type: String,
pub kb_progress: f64,
+ #[serde(skip_deserializing)]
pub created_at: Date,
+ #[serde(skip_deserializing)]
pub updated_at: Date,
- #[sea_orm(soft_delete_column)]
- pub is_deleted: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
diff --git a/src/entity/kb_info.rs b/src/entity/kb_info.rs
index 11cb3b2c24..46ce903b19 100644
--- a/src/entity/kb_info.rs
+++ b/src/entity/kb_info.rs
@@ -11,7 +11,9 @@ pub struct Model {
pub kn_name: String,
pub icon: i64,
+ #[serde(skip_deserializing)]
pub created_at: Date,
+ #[serde(skip_deserializing)]
pub updated_at: Date,
}
diff --git a/src/entity/tag_info.rs b/src/entity/tag_info.rs
index 230ed85586..f2a8efe3bc 100644
--- a/src/entity/tag_info.rs
+++ b/src/entity/tag_info.rs
@@ -14,7 +14,9 @@ pub struct Model {
pub icon: i64,
pub dir: String,
+ #[serde(skip_deserializing)]
pub created_at: Date,
+ #[serde(skip_deserializing)]
pub updated_at: Date,
}
diff --git a/src/entity/user_info.rs b/src/entity/user_info.rs
index 464d33e636..c706e3538a 100644
--- a/src/entity/user_info.rs
+++ b/src/entity/user_info.rs
@@ -14,8 +14,10 @@ pub struct Model {
pub list_style: String,
pub language: String,
- pub created_at: DateTimeWithTimeZone,
- pub updated_at: DateTimeWithTimeZone,
+ #[serde(skip_deserializing)]
+ pub created_at: Date,
+ #[serde(skip_deserializing)]
+ pub updated_at: Date,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
diff --git a/src/service/tag_info.rs b/src/service/tag_info.rs
index c0a3ce774e..656eb2c94b 100644
--- a/src/service/tag_info.rs
+++ b/src/service/tag_info.rs
@@ -1,3 +1,4 @@
+use chrono::{Local, NaiveDate};
use sea_orm::{ActiveModelTrait, DbConn, DbErr, DeleteResult, EntityTrait, PaginatorTrait, QueryOrder};
use sea_orm::ActiveValue::Set;
use crate::entity::tag_info;
@@ -38,15 +39,15 @@ impl Mutation {
form_data: tag_info::Model,
) -> Result<tag_info::ActiveModel, DbErr> {
tag_info::ActiveModel {
- tid: Set(form_data.tid.to_owned()),
+ tid: Default::default(),
uid: Set(form_data.uid.to_owned()),
tag_name: Set(form_data.tag_name.to_owned()),
regx: Set(form_data.regx.to_owned()),
color: Set(form_data.color.to_owned()),
icon: Set(form_data.icon.to_owned()),
dir: Set(form_data.dir.to_owned()),
- created_at: Default::default(),
- updated_at: Default::default(),
+ created_at: Set(Local::now().date_naive()),
+ updated_at: Set(Local::now().date_naive()),
}
.save(db)
.await
@@ -60,7 +61,7 @@ impl Mutation {
let tag: tag_info::ActiveModel = Entity::find_by_id(id)
.one(db)
.await?
- .ok_or(DbErr::Custom("Cannot find post.".to_owned()))
+ .ok_or(DbErr::Custom("Cannot find tag.".to_owned()))
.map(Into::into)?;
tag_info::ActiveModel {
@@ -72,7 +73,7 @@ impl Mutation {
icon: Set(form_data.icon.to_owned()),
dir: Set(form_data.dir.to_owned()),
created_at: Default::default(),
- updated_at: Default::default(),
+ updated_at: Set(Local::now().date_naive()),
}
.update(db)
.await