Go: fix dataset time unit (#14837)

### What problem does this PR solve?

fix dataset time unit

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
buua436
2026-05-12 17:22:16 +08:00
committed by GitHub
parent d08bf02d9b
commit 14332dd75c
3 changed files with 18 additions and 18 deletions

View File

@@ -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
}

View File

@@ -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

View File

@@ -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 {