Skip to content

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

Go: fix dataset time unit (#14837)

buua43614332dd75c32
diff --git a/internal/dao/kb.go b/internal/dao/kb.go
index d87051d983..0da2558e67 100644
--- a/internal/dao/kb.go
+++ b/internal/dao/kb.go
@@ -314,30 +314,30 @@ func splitNameCounter(name string) (string, int) {
// AtomicIncreaseDocNumByID atomically increments the document count
// This matches the Python atomic_increase_doc_num_by_id method
func (dao *KnowledgebaseDAO) AtomicIncreaseDocNumByID(kbID string) error {
- now := time.Now().Unix()
- nowDate := time.Now().Truncate(time.Second)
+ now := time.Now().Truncate(time.Second)
+ updateTime := now.UnixMilli()
return DB.Model(&entity.Knowledgebase{}).
Where("id = ?", kbID).
Updates(map[string]interface{}{
"doc_num": DB.Raw("doc_num + 1"),
- "update_time": now,
- "update_date": nowDate,
+ "update_time": updateTime,
+ "update_date": now,
}).Error
}
// DecreaseDocumentNum decreases document, chunk, and token counts
// This matches the Python decrease_document_num_in_delete method
func (dao *KnowledgebaseDAO) DecreaseDocumentNum(kbID string, docNum, chunkNum, tokenNum int64) error {
- now := time.Now().Unix()
- nowDate := time.Now().Truncate(time.Second)
+ now := time.Now().Truncate(time.Second)
+ updateTime := now.UnixMilli()
return DB.Model(&entity.Knowledgebase{}).
Where("id = ?", kbID).
Updates(map[string]interface{}{
"doc_num": DB.Raw("doc_num - ?", docNum),
"chunk_num": DB.Raw("chunk_num - ?", chunkNum),
"token_num": DB.Raw("token_num - ?", tokenNum),
- "update_time": now,
- "update_date": nowDate,
+ "update_time": updateTime,
+ "update_date": now,
}).Error
}
diff --git a/internal/service/datasets.go b/internal/service/datasets.go
index 4c9d64aff0..db1320e6eb 100644
--- a/internal/service/datasets.go
+++ b/internal/service/datasets.go
@@ -396,8 +396,8 @@ func (s *DatasetsService) CreateDataset(req *CreateDatasetRequest, tenantID stri
return nil, common.CodeServerError, errors.New("Internal server error")
}
- now := time.Now().Unix()
- nowDate := time.Now().Truncate(time.Second)
+ now := time.Now().Truncate(time.Second)
+ createTime := now.UnixMilli()
status := string(entity.StatusValid)
// Deduplicate name within tenant
duplicateName, err := common.DuplicateName(func(n, tid string) bool {
@@ -420,10 +420,10 @@ func (s *DatasetsService) CreateDataset(req *CreateDatasetRequest, tenantID stri
EmbdID: embdID,
Status: &status,
}
- kb.CreateTime = &now
- kb.UpdateTime = &now
- kb.CreateDate = &nowDate
- kb.UpdateDate = &nowDate
+ kb.CreateTime = &createTime
+ kb.UpdateTime = &createTime
+ kb.CreateDate = &now
+ kb.UpdateDate = &now
if description != nil {
kb.Description = description
diff --git a/internal/service/kb.go b/internal/service/kb.go
index 77d2577926..75916413b6 100644
--- a/internal/service/kb.go
+++ b/internal/service/kb.go
@@ -213,10 +213,10 @@ func (s *KnowledgebaseService) UpdateKB(req *UpdateKBRequest, userID string) (ma
updates["parser_config"] = req.ParserConfig
}
- now := time.Now().Unix()
- nowDate := time.Now().Truncate(time.Second)
- updates["update_time"] = now
- updates["update_date"] = nowDate
+ now := time.Now().Truncate(time.Second)
+ updateTime := now.UnixMilli()
+ updates["update_time"] = updateTime
+ updates["update_date"] = now
// Update in database
if err := s.kbDAO.UpdateByID(req.KBID, updates); err != nil {