Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pkg/app/ops/firestoreindexensurer/indexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 32 additions & 0 deletions pkg/app/ops/firestoreindexensurer/indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions pkg/app/ops/insightcollector/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (c *Collector) findDeploymentsCreatedInRange(ctx context.Context, from, to
Field: "CreatedAt",
Direction: datastore.Desc,
},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hosshii you may need to update firestore index as well to enable this query to work. Firestore indexes stored under pkg/app/ops/firestoreindexensurer/indexes.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thank you!

Field: "Id",
Direction: datastore.Asc,
},
},
})
if err != nil {
Expand Down Expand Up @@ -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 {
Expand Down
32 changes: 32 additions & 0 deletions pkg/app/ops/insightcollector/deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) {
Field: "CreatedAt",
Direction: datastore.Desc,
},
{
Field: "Id",
Direction: datastore.Asc,
},
},
}).Return([]*model.Deployment{
{
Expand Down Expand Up @@ -530,6 +534,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) {
Field: "CreatedAt",
Direction: datastore.Desc,
},
{
Field: "Id",
Direction: datastore.Asc,
},
},
}).Return([]*model.Deployment{
{
Expand Down Expand Up @@ -564,6 +572,10 @@ func TestFindDeploymentsCreatedInRange(t *testing.T) {
Field: "CreatedAt",
Direction: datastore.Desc,
},
{
Field: "Id",
Direction: datastore.Asc,
},
},
Cursor: "",
}).Return([]*model.Deployment{}, "", nil)
Expand Down Expand Up @@ -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"))
},
Expand Down Expand Up @@ -692,6 +708,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) {
Field: "CompletedAt",
Direction: datastore.Desc,
},
{
Field: "Id",
Direction: datastore.Asc,
},
},
}).Return([]*model.Deployment{
{
Expand Down Expand Up @@ -726,6 +746,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) {
Field: "CompletedAt",
Direction: datastore.Desc,
},
{
Field: "Id",
Direction: datastore.Asc,
},
},
}).Return([]*model.Deployment{
{
Expand Down Expand Up @@ -760,6 +784,10 @@ func TestFindDeploymentsCompletedInRange(t *testing.T) {
Field: "CompletedAt",
Direction: datastore.Desc,
},
{
Field: "Id",
Direction: datastore.Asc,
},
},
Cursor: "",
}).Return([]*model.Deployment{}, "", nil)
Expand Down Expand Up @@ -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"))
},
Expand Down