Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-12-01 19:30:45 +08:00
commit 2665671690
2 changed files with 14 additions and 2 deletions

View file

@ -1034,8 +1034,16 @@ func searchDocs(c *gin.Context) {
flashcard = arg["flashcard"].(bool)
}
var excludeIDs []string
if arg["excludeIDs"] != nil {
excludeIDsArg := arg["excludeIDs"].([]interface{})
for _, excludeID := range excludeIDsArg {
excludeIDs = append(excludeIDs, excludeID.(string))
}
}
k := arg["k"].(string)
ret.Data = model.SearchDocsByKeyword(k, flashcard)
ret.Data = model.SearchDocsByKeyword(k, flashcard, excludeIDs)
}
func listDocsByPath(c *gin.Context) {

View file

@ -139,7 +139,7 @@ func (box *Box) moveCorruptedData(filePath string) {
logging.LogWarnf("moved corrupted data file [%s] to [%s]", filePath, to)
}
func SearchDocsByKeyword(keyword string, flashcard bool) (ret []map[string]string) {
func SearchDocsByKeyword(keyword string, flashcard bool, excludeIDs []string) (ret []map[string]string) {
ret = []map[string]string{}
var deck *riff.Deck
@ -187,6 +187,10 @@ func SearchDocsByKeyword(keyword string, flashcard bool) (ret []map[string]strin
}
}
if 0 < len(excludeIDs) {
condition += fmt.Sprintf(" AND root_id NOT IN ('%s')", strings.Join(excludeIDs, "', '"))
}
rootBlocks = sql.QueryRootBlockByCondition(condition, Conf.Search.Limit)
} else {
for _, box := range boxes {