~james/core

core/api/org_tangled/searchquery.go -rw-r--r-- 3.6 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package org_tangled

// schema: org.tangled.search.query

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	SearchQueryNSID = "org.tangled.search.query"
)

// SearchQuery_Hit is a "hit" in the org.tangled.search.query schema.
type SearchQuery_Hit struct {
	// author: Present for tickets. The account that opened the ticket, the editor of its first version.
	Author *string `json:"author,omitempty" cborgen:"author,omitempty"`
	Cid    *string `json:"cid,omitempty" cborgen:"cid,omitempty"`
	// commentCount: Present for tickets.
	CommentCount *int64 `json:"commentCount,omitempty" cborgen:"commentCount,omitempty"`
	// nsid: Collection of the matched record.
	Nsid string `json:"nsid" cborgen:"nsid"`
	// score: Relevance score of the hit, a floating-point number where higher ranks first.
	Score *util.LexiconTypeDecoder `json:"score" cborgen:"score"`
	// state: Present for tickets.
	State *string `json:"state,omitempty" cborgen:"state,omitempty"`
	Uri   string  `json:"uri" cborgen:"uri"`
	// value: Embedded matched record.
	Value *util.LexiconTypeDecoder `json:"value" cborgen:"value"`
}

// SearchQuery_Output is the output of a org.tangled.search.query call.
type SearchQuery_Output struct {
	Cursor *string            `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Hits   []*SearchQuery_Hit `json:"hits" cborgen:"hits"`
	// stateCounts: Matches per ticket state, without the state filters.
	StateCounts *SearchQuery_StateCounts `json:"stateCounts,omitempty" cborgen:"stateCounts,omitempty"`
	// total: Number of matches across all pages.
	Total *int64 `json:"total,omitempty" cborgen:"total,omitempty"`
}

// SearchQuery_StateCounts is a "stateCounts" in the org.tangled.search.query schema.
type SearchQuery_StateCounts struct {
	Closed    int64 `json:"closed" cborgen:"closed"`
	Completed int64 `json:"completed" cborgen:"completed"`
	Open      int64 `json:"open" cborgen:"open"`
}

// SearchQuery calls the XRPC method "org.tangled.search.query".
//
// author: Restrict to records authored by this DID.
// cursor: Pagination cursor
// kind: Restrict tickets to issues or pull requests.
// label: Restrict tickets to those with all of these label names. Requires repo.
// nsid: Restrict to records of this collection.
// offset: Absolute offset for numbered pages. Mutually exclusive with cursor.
// q: Search query: free text plus key:value qualifiers. See the docs for more information.
// repo: Restrict to records under this repo DID.
// since: Restrict to records created at or after this time.
// sort: Result order.
// until: Restrict to records created at or before this time.
func SearchQuery(ctx context.Context, c util.LexClient, author string, cursor string, kind string, label []string, limit int64, nsid string, offset int64, q string, repo string, since string, sort string, until string) (*SearchQuery_Output, error) {
	var out SearchQuery_Output

	params := map[string]interface{}{}
	if author != "" {
		params["author"] = author
	}
	if cursor != "" {
		params["cursor"] = cursor
	}
	if kind != "" {
		params["kind"] = kind
	}
	if len(label) != 0 {
		params["label"] = label
	}
	if limit != 0 {
		params["limit"] = limit
	}
	if nsid != "" {
		params["nsid"] = nsid
	}
	if offset != 0 {
		params["offset"] = offset
	}
	if q != "" {
		params["q"] = q
	}
	if repo != "" {
		params["repo"] = repo
	}
	if since != "" {
		params["since"] = since
	}
	if sort != "" {
		params["sort"] = sort
	}
	if until != "" {
		params["until"] = until
	}
	if err := c.LexDo(ctx, util.Query, "", "org.tangled.search.query", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}