Closed mplekunov closed 1 year ago
All sorting parameters except sortByRecipe have isReverse implemented which allows to do reverse of every sorting type.
Sorting methods:
Abstracted some similar sorting algorithms in the new BaseIngredientController class
isReverse for sortRecipe cannot be implemented as for right now because in this sorting key (property) of the object would be a number. As per https://tc39.es/ecma262/#sec-ordinaryownpropertykeys number properties are considered as indexes during Object.fromEntries conversion. Therefore the sorting applied before Object conversion will not be persistent.
isReverse for sortRecipe cannot be implemented as for right now because in this sorting key (property) of the object would be a number. As per https://tc39.es/ecma262/#sec-ordinaryownpropertykeys number properties are considered as indexes during Object.fromEntries conversion. Therefore the sorting applied before Object conversion will not be persistent.
We discussed this over DM and our approach is to not convert to object before returning; the format of the response will be (afaiu) an array of arrays, where each nested array corresponds to a single item of the response. @mplekunov Can you type out a a sample response here so that it's clear what the frontend should expect?
isReverse for sortRecipe cannot be implemented as for right now because in this sorting key (property) of the object would be a number. As per https://tc39.es/ecma262/#sec-ordinaryownpropertykeys number properties are considered as indexes during Object.fromEntries conversion. Therefore the sorting applied before Object conversion will not be persistent.
We discussed this over DM and our approach is to not convert to object before returning; the format of the response will be (afaiu) an array of arrays, where each nested array corresponds to a single item of the response. @mplekunov Can you type out a a sample response here so that it's clear what the frontend should expect?
"itemsWithRecipeID": [
[
"1",
[
{
"id": 184271,
"name": "B",
"category": "catA",
"quantityUnits": [
"g",
"kg"
],
"quantity": {
"unit": "gas",
"value": 2
},
"recipeID": 1,
"itemID": "6379561ec592584f35a64f30"
}
]
],
[
"2",
[
{
"id": 184270,
"name": "B",
"category": "catA",
"quantityUnits": [
"g",
"kg"
],
"quantity": {
"unit": "gas",
"value": 2
},
"recipeID": 2,
"itemID": "6379553582a1557016d9a784"
},
{
"id": 184271,
"name": "B",
"category": "catA",
"quantityUnits": [
"g",
"kg"
],
"quantity": {
"unit": "gas",
"value": 2
},
"recipeID": 2,
"itemID": "637955f6c592584f35a64f2f"
}
]
]
],
"itemsWithoutRecipeID": []
}
isReverse for sortRecipe cannot be implemented as for right now because in this sorting key (property) of the object would be a number. As per https://tc39.es/ecma262/#sec-ordinaryownpropertykeys number properties are considered as indexes during Object.fromEntries conversion. Therefore the sorting applied before Object conversion will not be persistent.
We discussed this over DM and our approach is to not convert to object before returning; the format of the response will be (afaiu) an array of arrays, where each nested array corresponds to a single item of the response. @mplekunov Can you type out a a sample response here so that it's clear what the frontend should expect?
"itemsWithRecipeID": [ [ "1", [ { "id": 184271, "name": "B", "category": "catA", "quantityUnits": [ "g", "kg" ], "quantity": { "unit": "gas", "value": 2 }, "recipeID": 1, "itemID": "6379561ec592584f35a64f30" } ] ], [ "2", [ { "id": 184270, "name": "B", "category": "catA", "quantityUnits": [ "g", "kg" ], "quantity": { "unit": "gas", "value": 2 }, "recipeID": 2, "itemID": "6379553582a1557016d9a784" }, { "id": 184271, "name": "B", "category": "catA", "quantityUnits": [ "g", "kg" ], "quantity": { "unit": "gas", "value": 2 }, "recipeID": 2, "itemID": "637955f6c592584f35a64f2f" } ] ] ], "itemsWithoutRecipeID": [] }
where 1 and 2 are recipeIDs
Depends on #88