refactor(documents): rename document tree model
This commit is contained in:
@@ -92,7 +92,7 @@ func (s *Service) Search(userID uint, query string) ([]SearchResultDTO, error) {
|
||||
})
|
||||
}
|
||||
|
||||
var documents []models.SaDocument
|
||||
var documents []models.SaDocumentTree
|
||||
documentFilter := fmt.Sprintf(`(sa_projects.owner_id = ? OR EXISTS (
|
||||
SELECT 1 FROM sa_task_shares
|
||||
JOIN sa_tasks ON sa_tasks.id = sa_task_shares.task_id
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestPostgresSearchMatchesChinesePartialKeywords(t *testing.T) {
|
||||
project := models.SaProject{OwnerID: owner.ID, Name: "中文回调平台", Identifier: "PG-CALLBACK"}
|
||||
require.NoError(t, database.Create(&project).Error)
|
||||
require.NoError(t, database.Create(&models.SaTask{ProjectID: project.ID, CreatedBy: owner.ID, Title: "回调任务", Status: "open"}).Error)
|
||||
createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocument{Name: "说明.md"}, "回调验签流程")
|
||||
createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocumentTree{Name: "说明.md"}, "回调验签流程")
|
||||
|
||||
results, err := NewService(database).Search(owner.ID, "回调")
|
||||
|
||||
@@ -38,8 +38,8 @@ func TestPostgresSearchKeepsAssignmentAndExplicitShareBoundaries(t *testing.T) {
|
||||
assigned := models.SaTask{ProjectID: project.ID, CreatedBy: owner.ID, AssigneeID: &viewer.ID, Title: "边界词已指派", Status: "open"}
|
||||
require.NoError(t, database.Create(&assigned).Error)
|
||||
require.NoError(t, database.Create(&models.SaTask{ProjectID: project.ID, CreatedBy: owner.ID, Title: "边界词私有任务", Status: "open"}).Error)
|
||||
sharedDocument := createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocument{Name: "边界词共享笔记.md"}, "")
|
||||
createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocument{Name: "边界词私有笔记.md"}, "")
|
||||
sharedDocument := createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocumentTree{Name: "边界词共享笔记.md"}, "")
|
||||
createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocumentTree{Name: "边界词私有笔记.md"}, "")
|
||||
require.NoError(t, database.Create(&models.SaTaskShare{TaskID: assigned.ID, ObjectType: "document", ObjectID: sharedDocument.ID}).Error)
|
||||
|
||||
results, err := NewService(database).Search(viewer.ID, "边界词")
|
||||
@@ -70,7 +70,7 @@ func TestPostgresSearchUsesStableFairLimitAndRuneBoundedSnippets(t *testing.T) {
|
||||
Status: "open",
|
||||
UpdatedAt: baseTime.Add(time.Duration(index) * time.Minute),
|
||||
}).Error)
|
||||
createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocument{
|
||||
createPostgresSearchDocument(t, database, project, owner.ID, models.SaDocumentTree{
|
||||
Identity: fmt.Sprintf("00000000-0000-7003-8000-%012d", index),
|
||||
Name: fmt.Sprintf("稳定排序笔记 %02d.md", index),
|
||||
UpdatedAt: baseTime.Add(time.Duration(index) * time.Minute),
|
||||
@@ -110,9 +110,9 @@ func createPostgresSearchDocument(
|
||||
database *gorm.DB,
|
||||
project models.SaProject,
|
||||
ownerID uint,
|
||||
document models.SaDocument,
|
||||
document models.SaDocumentTree,
|
||||
markdown string,
|
||||
) models.SaDocument {
|
||||
) models.SaDocumentTree {
|
||||
t.Helper()
|
||||
document.ProjectID = project.ID
|
||||
document.ProjectIdentity = project.Identity
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestSearchAppliesStableFairGlobalLimitAcrossResultTypes(t *testing.T) {
|
||||
Status: "open",
|
||||
UpdatedAt: baseTime.Add(time.Duration(index) * time.Minute),
|
||||
}).Error)
|
||||
document := models.SaDocument{
|
||||
document := models.SaDocumentTree{
|
||||
Identity: fmt.Sprintf("00000000-0000-7003-8000-%012d", index),
|
||||
ProjectID: project.ID,
|
||||
CreatedBy: 7,
|
||||
@@ -136,9 +136,9 @@ func TestSearchOnlyReturnsNavigableProjectTaskAndDocumentResults(t *testing.T) {
|
||||
require.Len(t, results, 3)
|
||||
}
|
||||
|
||||
func createSearchDocument(t *testing.T, database *gorm.DB, projectID, userID uint, name, markdown, identity string, updatedAt time.Time) models.SaDocument {
|
||||
func createSearchDocument(t *testing.T, database *gorm.DB, projectID, userID uint, name, markdown, identity string, updatedAt time.Time) models.SaDocumentTree {
|
||||
t.Helper()
|
||||
document := models.SaDocument{
|
||||
document := models.SaDocumentTree{
|
||||
Identity: identity, ProjectID: projectID, CreatedBy: userID, Kind: models.DocumentKindFile,
|
||||
Name: name, NormalizedName: strings.ToLower(name), Extension: ".md",
|
||||
MimeType: "text/markdown", Size: int64(len([]byte(markdown))), Revision: 1,
|
||||
|
||||
Reference in New Issue
Block a user