Skip to content

Commit

Permalink
optimize get app cost with index(owner+order_id) (labring#5002)
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 authored Aug 28, 2024
1 parent 80f4682 commit 3c418c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion service/account/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ func CheckAuthAndCalibrate(auth *helper.Auth) (err error) {
if err != nil {
return fmt.Errorf("get user cr name error: %v", err)
}
fmt.Printf("auth: %v\n", auth)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions service/account/dao/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (m *MongoDB) GetAppCostsByOrderIDAndAppName(req *helper.AppCostsReq) ([]com
var pipeline mongo.Pipeline
if req.AppType == resources.AppStore {
pipeline = mongo.Pipeline{
{{Key: "$match", Value: bson.D{{Key: "order_id", Value: req.OrderID}}}},
{{Key: "$match", Value: bson.D{{Key: "order_id", Value: req.OrderID}, {Key: "owner", Value: req.Owner}}}},
{{Key: "$unwind", Value: "$app_costs"}},
{{Key: "$project", Value: bson.D{
{Key: "app_name", Value: "$app_costs.name"},
Expand All @@ -441,7 +441,7 @@ func (m *MongoDB) GetAppCostsByOrderIDAndAppName(req *helper.AppCostsReq) ([]com
}
} else {
pipeline = mongo.Pipeline{
{{Key: "$match", Value: bson.D{{Key: "order_id", Value: req.OrderID}}}},
{{Key: "$match", Value: bson.D{{Key: "order_id", Value: req.OrderID}, {Key: "owner", Value: req.Owner}}}},
{{Key: "$unwind", Value: "$app_costs"}},
{{Key: "$match", Value: bson.D{{Key: "app_costs.name", Value: req.AppName}}}},
{{Key: "$project", Value: bson.D{
Expand Down

0 comments on commit 3c418c3

Please sign in to comment.