mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-18 20:10:04 +02:00
fix: remove assignee_id
This commit is contained in:
parent
af45c5689f
commit
09131dc34c
@ -16,7 +16,7 @@ import (
|
||||
"gitea.dev/modules/util"
|
||||
)
|
||||
|
||||
const issueIndexerLatestVersion = 3
|
||||
const issueIndexerLatestVersion = 4
|
||||
|
||||
var _ internal.Indexer = &Indexer{}
|
||||
|
||||
@ -57,7 +57,8 @@ const (
|
||||
"project_ids": { "type": "integer", "index": true },
|
||||
"no_project": { "type": "boolean", "index": true },
|
||||
"poster_id": { "type": "integer", "index": true },
|
||||
"assignee_id": { "type": "integer", "index": true },
|
||||
"assignee_ids": { "type": "integer", "index": true },
|
||||
"no_assignee": { "type": "boolean", "index": true },
|
||||
"mention_ids": { "type": "integer", "index": true },
|
||||
"reviewed_ids": { "type": "integer", "index": true },
|
||||
"review_requested_ids": { "type": "integer", "index": true },
|
||||
@ -177,14 +178,15 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||
query.Must(es.TermQuery("poster_id", posterIDInt64))
|
||||
}
|
||||
|
||||
if options.AssigneeID != "" {
|
||||
if options.AssigneeID == "(any)" {
|
||||
query.Must(es.NewRangeQuery("assignee_id").Gte(1))
|
||||
} else {
|
||||
// "(none)" becomes 0, it means no assignee
|
||||
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
|
||||
query.Must(es.TermQuery("assignee_id", assigneeIDInt64))
|
||||
}
|
||||
switch options.AssigneeID {
|
||||
case "":
|
||||
case "(any)":
|
||||
query.Must(es.TermQuery("no_assignee", false))
|
||||
case "(none)":
|
||||
query.Must(es.TermQuery("no_assignee", true))
|
||||
default:
|
||||
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
|
||||
query.Must(es.TermQuery("assignee_ids", assigneeIDInt64))
|
||||
}
|
||||
|
||||
if options.MentionID.Has() {
|
||||
|
||||
@ -34,7 +34,6 @@ type IndexerData struct {
|
||||
NoProject bool `json:"no_project"` // True if ProjectIDs is empty
|
||||
ProjectColumnMap map[int64]int64 `json:"project_column_map,omitempty"` // Maps project ID to column ID for each project the issue is in
|
||||
PosterID int64 `json:"poster_id"`
|
||||
AssigneeID int64 `json:"assignee_id"`
|
||||
AssigneeIDs []int64 `json:"assignee_ids"`
|
||||
NoAssignee bool `json:"no_assignee"` // True if the issue has no assignees
|
||||
MentionIDs []int64 `json:"mention_ids"`
|
||||
|
||||
@ -686,11 +686,9 @@ func generateDefaultIndexerData() []*internal.IndexerData {
|
||||
for i := range projectIDs {
|
||||
projectIDs[i] = int64(i) + 1 // projectID should not be 0
|
||||
}
|
||||
assigneeID := issueIndex % 10
|
||||
|
||||
var assigneeIDs []int64
|
||||
if assigneeID != 0 {
|
||||
assigneeIDs = []int64{assigneeID}
|
||||
if issueIndex%10 != 0 {
|
||||
assigneeIDs = []int64{issueIndex % 10}
|
||||
}
|
||||
|
||||
data = append(data, &internal.IndexerData{
|
||||
@ -708,9 +706,8 @@ func generateDefaultIndexerData() []*internal.IndexerData {
|
||||
ProjectIDs: projectIDs,
|
||||
NoProject: len(projectIDs) == 0,
|
||||
PosterID: id%10 + 1, // PosterID should not be 0
|
||||
AssigneeID: assigneeID,
|
||||
AssigneeIDs: assigneeIDs,
|
||||
NoAssignee: assigneeID == 0,
|
||||
NoAssignee: len(assigneeIDs) == 0,
|
||||
MentionIDs: mentionIDs,
|
||||
ReviewedIDs: reviewedIDs,
|
||||
ReviewRequestedIDs: reviewRequestedIDs,
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
issueIndexerLatestVersion = 5
|
||||
issueIndexerLatestVersion = 6
|
||||
|
||||
// TODO: make this configurable if necessary
|
||||
maxTotalHits = 10000
|
||||
@ -74,7 +74,8 @@ func NewIndexer(url, apiKey, indexerName string) *Indexer {
|
||||
"project_ids",
|
||||
"no_project",
|
||||
"poster_id",
|
||||
"assignee_id",
|
||||
"assignee_ids",
|
||||
"no_assignee",
|
||||
"mention_ids",
|
||||
"reviewed_ids",
|
||||
"review_requested_ids",
|
||||
@ -195,14 +196,15 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||
query.And(inner_meilisearch.NewFilterEq("poster_id", posterIDInt64))
|
||||
}
|
||||
|
||||
if options.AssigneeID != "" {
|
||||
if options.AssigneeID == "(any)" {
|
||||
query.And(inner_meilisearch.NewFilterGte("assignee_id", 1))
|
||||
} else {
|
||||
// "(none)" becomes 0, it means no assignee
|
||||
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
|
||||
query.And(inner_meilisearch.NewFilterEq("assignee_id", assigneeIDInt64))
|
||||
}
|
||||
switch options.AssigneeID {
|
||||
case "":
|
||||
case "(any)":
|
||||
query.And(inner_meilisearch.NewFilterEq("no_assignee", false))
|
||||
case "(none)":
|
||||
query.And(inner_meilisearch.NewFilterEq("no_assignee", true))
|
||||
default:
|
||||
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
|
||||
query.And(inner_meilisearch.NewFilterEq("assignee_ids", assigneeIDInt64))
|
||||
}
|
||||
|
||||
if options.MentionID.Has() {
|
||||
|
||||
@ -117,7 +117,6 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
|
||||
ProjectIDs: projectIDs,
|
||||
NoProject: len(projectIDs) == 0,
|
||||
PosterID: issue.PosterID,
|
||||
AssigneeID: issue.AssigneeID,
|
||||
AssigneeIDs: assigneeIDs,
|
||||
NoAssignee: len(assigneeIDs) == 0,
|
||||
MentionIDs: mentionIDs,
|
||||
|
||||
@ -18,6 +18,14 @@ import (
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
func assertSameFileMetadata(t *testing.T, expected, actual os.FileInfo) {
|
||||
t.Helper()
|
||||
assert.Equal(t, expected.Name(), actual.Name())
|
||||
assert.Equal(t, expected.Size(), actual.Size())
|
||||
assert.Equal(t, expected.Mode(), actual.Mode())
|
||||
assert.Equal(t, expected.ModTime(), actual.ModTime())
|
||||
}
|
||||
|
||||
func TestGenKeyPair(t *testing.T) {
|
||||
testCases := []struct {
|
||||
keyType generate.SSHKeyType
|
||||
@ -106,11 +114,11 @@ func TestInitKeys(t *testing.T) {
|
||||
// No modification to RSA key
|
||||
infoPub, err := os.Stat(pubKeyPath)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata[privKeyPath], infoPriv)
|
||||
assert.Equal(t, metadata[pubKeyPath], infoPub)
|
||||
assertSameFileMetadata(t, metadata[privKeyPath], infoPriv)
|
||||
assertSameFileMetadata(t, metadata[pubKeyPath], infoPub)
|
||||
case "ecdsa":
|
||||
// ECDSA public key should be missing, private unchanged
|
||||
assert.Equal(t, metadata[privKeyPath], infoPriv)
|
||||
assertSameFileMetadata(t, metadata[privKeyPath], infoPriv)
|
||||
assert.NoFileExists(t, pubKeyPath)
|
||||
case "ed25519":
|
||||
// ed25519 private key was removed, so both keys regenerated
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user