diff --git a/backend/internal/db/mongo/item_misc.go b/backend/internal/db/mongo/item_misc.go index 83ff547..2f86d7c 100644 --- a/backend/internal/db/mongo/item_misc.go +++ b/backend/internal/db/mongo/item_misc.go @@ -95,50 +95,26 @@ func (b *Backend) GetIncoherentItems(ctx context.Context, page, size uint64, cat var items []*models.Item filter := bson.M{ - "$or": []bson.M{ + "$and": []bson.M{ { - "$and": []bson.M{ - { - "deleted_at": bson.M{ - "$exists": false, - }, - }, - { - "amount_left": bson.M{ - "$gt": 0, - }, - }, - { - "state": bson.M{ - "$ne": "buyable", - }, - }, - { - "$or": []bson.M{ - {"display_prices.ceten": 0}, - {"display_prices.coutant": 0}, - {"display_prices.externe": 0}, - {"display_prices.menu": 0}, - {"display_prices.privilegies": 0}, - {"display_prices.staff_bar": 0}, - {"prices.ceten": 0}, - {"prices.coutant": 0}, - {"prices.externe": 0}, - {"prices.menu": 0}, - {"prices.privilegies": 0}, - {"prices.staff_bar": 0}, - }, - }, - }, + "deleted_at": nil, }, { - "amount_left": bson.M{ - "$gt": 0, - }, - "state": bson.M{ - "$ne": "buyable", - }, "$or": []bson.M{ + { + "$and": []bson.M{ + { + "amount_left": bson.M{ + "$gt": 0, + }, + }, + { + "state": bson.M{ + "$ne": "buyable", + }, + }, + }, + }, {"display_prices.ceten": 0}, {"display_prices.coutant": 0}, {"display_prices.externe": 0}, @@ -155,7 +131,6 @@ func (b *Backend) GetIncoherentItems(ctx context.Context, page, size uint64, cat }, }, } - if state != "" { filter["state"] = state if state == string(autogen.ItemBuyable) { @@ -286,50 +261,26 @@ func (b *Backend) CountIncoherentItems(ctx context.Context, categoryID string, s defer cancel() filter := bson.M{ - "$or": []bson.M{ + "$and": []bson.M{ { - "$and": []bson.M{ - { - "deleted_at": bson.M{ - "$exists": false, - }, - }, - { - "amount_left": bson.M{ - "$gt": 0, - }, - }, - { - "state": bson.M{ - "$ne": "buyable", - }, - }, - { - "$or": []bson.M{ - {"display_prices.ceten": 0}, - {"display_prices.coutant": 0}, - {"display_prices.externe": 0}, - {"display_prices.menu": 0}, - {"display_prices.privilegies": 0}, - {"display_prices.staff_bar": 0}, - {"prices.ceten": 0}, - {"prices.coutant": 0}, - {"prices.externe": 0}, - {"prices.menu": 0}, - {"prices.privilegies": 0}, - {"prices.staff_bar": 0}, - }, - }, - }, + "deleted_at": nil, }, { - "amount_left": bson.M{ - "$gt": 0, - }, - "state": bson.M{ - "$ne": "buyable", - }, "$or": []bson.M{ + { + "$and": []bson.M{ + { + "amount_left": bson.M{ + "$gt": 0, + }, + }, + { + "state": bson.M{ + "$ne": "buyable", + }, + }, + }, + }, {"display_prices.ceten": 0}, {"display_prices.coutant": 0}, {"display_prices.externe": 0}, @@ -395,4 +346,4 @@ func (b *Backend) CountIncoherentItems(ctx context.Context, categoryID string, s } return uint64(count), nil -} \ No newline at end of file +}