From 6e526c0a8f691d0450b901f4fa5ff6dd693eae2a Mon Sep 17 00:00:00 2001 From: Hosshii Date: Fri, 11 Mar 2022 14:08:41 +0900 Subject: [PATCH 1/4] add id to condition --- pkg/app/ops/insightcollector/deployments.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/app/ops/insightcollector/deployments.go b/pkg/app/ops/insightcollector/deployments.go index 488e685068..8ab0fdc1ed 100644 --- a/pkg/app/ops/insightcollector/deployments.go +++ b/pkg/app/ops/insightcollector/deployments.go @@ -93,6 +93,10 @@ func (c *Collector) findDeploymentsCreatedInRange(ctx context.Context, from, to Field: "CreatedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }) if err != nil { @@ -133,6 +137,10 @@ func (c *Collector) findDeploymentsCompletedInRange(ctx context.Context, from, t Field: "CompletedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }) if err != nil { From dd3014a20af9ce72fc5a0b442dbc304c250f08da Mon Sep 17 00:00:00 2001 From: Hosshii Date: Fri, 11 Mar 2022 15:05:43 +0900 Subject: [PATCH 2/4] fix test --- .../ops/insightcollector/deployments_test.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/app/ops/insightcollector/deployments_test.go b/pkg/app/ops/insightcollector/deployments_test.go index bce0a91554..d995168f7e 100644 --- a/pkg/app/ops/insightcollector/deployments_test.go +++ b/pkg/app/ops/insightcollector/deployments_test.go @@ -496,6 +496,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) { Field: "CreatedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }).Return([]*model.Deployment{ { @@ -530,6 +534,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) { Field: "CreatedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }).Return([]*model.Deployment{ { @@ -564,6 +572,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) { Field: "CreatedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, Cursor: "", }).Return([]*model.Deployment{}, "", nil) @@ -621,6 +633,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) { Field: "CreatedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }).Return([]*model.Deployment{}, "", fmt.Errorf("something wrong happens in ListDeployments")) }, @@ -692,6 +708,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) { Field: "CompletedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }).Return([]*model.Deployment{ { @@ -726,6 +746,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) { Field: "CompletedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }).Return([]*model.Deployment{ { @@ -760,6 +784,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) { Field: "CompletedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, Cursor: "", }).Return([]*model.Deployment{}, "", nil) @@ -817,6 +845,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) { Field: "CompletedAt", Direction: datastore.Desc, }, + { + Field: "Id", + Direction: datastore.Asc, + }, }, }).Return([]*model.Deployment{}, "", fmt.Errorf("something wrong happens in ListDeployments")) }, From 4230c98adf3682c755a0deeaec87b9b3a943f31c Mon Sep 17 00:00:00 2001 From: Hosshii Date: Fri, 11 Mar 2022 15:14:52 +0900 Subject: [PATCH 3/4] add index --- .../ops/firestoreindexensurer/indexes.json | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/app/ops/firestoreindexensurer/indexes.json b/pkg/app/ops/firestoreindexensurer/indexes.json index 1d77952f45..b529ba32fe 100644 --- a/pkg/app/ops/firestoreindexensurer/indexes.json +++ b/pkg/app/ops/firestoreindexensurer/indexes.json @@ -309,6 +309,38 @@ } ] }, + { + "collectionGroup": "Deployment", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "CompletedAt", + "order": "DESCENDING", + "arrayConfig": "" + }, + { + "fieldPath": "Id", + "order": "ASCENDING", + "arrayConfig": "" + } + ] + }, + { + "collectionGroup": "Deployment", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "CreatedAt", + "order": "DESCENDING", + "arrayConfig": "" + }, + { + "fieldPath": "Id", + "order": "ASCENDING", + "arrayConfig": "" + } + ] + }, { "collectionGroup": "Event", "queryScope": "COLLECTION", From bc66107e4d6be7202058e6d210ac36a13b12797f Mon Sep 17 00:00:00 2001 From: Hosshii Date: Fri, 11 Mar 2022 15:17:27 +0900 Subject: [PATCH 4/4] add test --- .../ops/firestoreindexensurer/indexes_test.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/app/ops/firestoreindexensurer/indexes_test.go b/pkg/app/ops/firestoreindexensurer/indexes_test.go index 2a1b73469b..db5f88c830 100644 --- a/pkg/app/ops/firestoreindexensurer/indexes_test.go +++ b/pkg/app/ops/firestoreindexensurer/indexes_test.go @@ -333,6 +333,38 @@ func TestParseIndexes(t *testing.T) { }, }, }, + { + CollectionGroup: "Deployment", + QueryScope: "COLLECTION", + Fields: []field{ + { + FieldPath: "CompletedAt", + Order: "DESCENDING", + ArrayConfig: "", + }, + { + FieldPath: "Id", + Order: "ASCENDING", + ArrayConfig: "", + }, + }, + }, + { + CollectionGroup: "Deployment", + QueryScope: "COLLECTION", + Fields: []field{ + { + FieldPath: "CreatedAt", + Order: "DESCENDING", + ArrayConfig: "", + }, + { + FieldPath: "Id", + Order: "ASCENDING", + ArrayConfig: "", + }, + }, + }, { CollectionGroup: "Event", QueryScope: "COLLECTION",