mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-12 12:58:02 -05:00
Tag query change (#44)
* Tag query change --------- Co-authored-by: Icereed <domi@icereed.net>
This commit is contained in:
parent
6d4683c9a3
commit
d1f23de5a6
2 changed files with 4 additions and 4 deletions
|
@ -108,10 +108,10 @@ func (c *PaperlessClient) GetAllTags(ctx context.Context) (map[string]int, error
|
|||
func (c *PaperlessClient) GetDocumentsByTags(ctx context.Context, tags []string) ([]Document, error) {
|
||||
tagQueries := make([]string, len(tags))
|
||||
for i, tag := range tags {
|
||||
tagQueries[i] = fmt.Sprintf("tag:%s", tag)
|
||||
tagQueries[i] = fmt.Sprintf("tags__name__iexact=%s", tag)
|
||||
}
|
||||
searchQuery := strings.Join(tagQueries, " ")
|
||||
path := fmt.Sprintf("api/documents/?query=%s", urlEncode(searchQuery))
|
||||
searchQuery := strings.Join(tagQueries, "&")
|
||||
path := fmt.Sprintf("api/documents/?%s", urlEncode(searchQuery))
|
||||
|
||||
resp, err := c.Do(ctx, "GET", path, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -203,7 +203,7 @@ func TestGetDocumentsByTags(t *testing.T) {
|
|||
// Set mock responses
|
||||
env.setMockResponse("/api/documents/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// Verify query parameters
|
||||
expectedQuery := "query=tag:tag1+tag:tag2"
|
||||
expectedQuery := "tags__name__iexact=tag1&tags__name__iexact=tag2"
|
||||
assert.Equal(t, expectedQuery, r.URL.RawQuery)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(documentsResponse)
|
||||
|
|
Loading…
Reference in a new issue