Related
I saw several articles here on stackoverflow but I couldn't get my pagination working with mongodb and spring boot. The code always returns only one result when I change the value of the limit or skip variable the result is always nothing.
My Repository:
public interface CategoryProductRepository extends MongoRepository<CategoryProduct, String> {
#Aggregation(pipeline = {
"{ '$match': { 'categories.category_id' : ?0 } }",
"{ '$skip' : ?1 }",
"{ '$limit' : ?2 }"
})
List<CategoryProduct> findCategoriesCategoryId(
Long field0,
Long skip,
Long limit
);
}
My structure:
[
{
"product_id": 4,
"id_colletion": 4,
"product_tite": "Testar",
"product_quant": 50,
"product_slug": "slug6",
"product_active": "ativo",
"product_description": "description",
"product_price_un": 50,
"product_price_kg": 10.25,
"star": 0,
"photos": [
{
"photo": "url",
"type": "mini",
"title": "título",
"active": "ativo"
},
{
"photo": "url 2",
"type": "mini",
"title": "título 2",
"active": "ativo"
}
],
"categories": [
{
"category_id": 1,
"name": "categoria 1",
"active": "ativo"
},
{
"category_id": 2,
"name": "categoria 2",
"active": "ativo"
}
]
},
{
"product_id": 5,
"id_colletion": 5,
"product_tite": "new",
"product_quant": 50,
"product_slug": "slugnew",
"product_active": "ativo",
"product_description": "descriptionnew",
"product_price_un": 50,
"product_price_kg": 10.25,
"star": 0,
"photos": [
{
"photo_id": 13,
"photo": "photo 11",
"type": "mini",
"title": "photo 11",
"active": "ativo"
}
],
"categories": [
{
"category_id": 1,
"name": "categoria 1",
"active": "ativo"
}
]
},
{
"product_id": 9,
"id_colletion": 9,
"product_tite": "2",
"product_quant": 2,
"product_slug": "slugnew2",
"product_active": "ativo",
"product_description": "2",
"product_price_un": 2,
"product_price_kg": 2,
"star": 0,
"photos": [
{
"photo": "photo 2",
"type": "mini",
"title": "photo 2",
"active": "desativo"
}
],
"categories": [
{
"category_id": 2,
"name": "categoria 2",
"active": "ativo"
}
]
}
]
Does anyone have any idea where my mistake is?
[SOLVED]
I was inserting the limit and skip wrong but the code works fine
I have an use case, where user is defined a workflow. As user hits the API, step function gets started. A lambda returns a list of steps based on users & start the workflow e.g.:
step1. it process(extracts) the doc,
step2. inserts some data to
DB
step3. .....
step4. .....
here steps are in map, as these steps are returned from lambda.
Is there any way to get response from each map iteration, so that I can show user at which step the process is , & the output of previous step.
here is my step function design:
test-fetch-input-workflow: returns an array: [step1, step2, ....]
workflow step-lambda: calls some lambda based on step name
Assuming that you are using Standard Workflows, you can get this information using the GetExecutionHistory API Action: https://docs.aws.amazon.com/step-functions/latest/apireference/API_GetExecutionHistory.html
You will want to look for events of type MapIterationSucceeded, grab the previousEventId, then look for the output in the HistoryEvent with that Id.
For example, if you had a state machine like this:
{
"StartAt": "Generate Array for Map",
"States": {
"Generate Array for Map": {
"Type": "Pass",
"Next": "Map",
"Result": [
1,
2,
3,
4,
5
]
},
"Map": {
"Type": "Map",
"ItemProcessor": {
"ProcessorConfig": {
"Mode": "INLINE"
},
"StartAt": "Generate Random Number",
"States": {
"Generate Random Number": {
"Type": "Pass",
"End": true,
"Parameters": {
"Random Number.$": "States.MathRandom(1,1000)"
}
}
}
},
"End": true
}
}
}
Your execution history would look like this:
{
"events": [
{
"timestamp": "2022-12-08T16:44:07.651000-08:00",
"type": "ExecutionStarted",
"id": 1,
"previousEventId": 0,
"executionStartedEventDetails": {
"input": "{\n \"Comment\": \"Insert your JSON here\"\n}",
"inputDetails": {
"truncated": false
},
"roleArn": "arn:aws:iam::000000000000:role/service-role/StepFunctions-MapTest-role-613230dd"
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 2,
"previousEventId": 0,
"stateEnteredEventDetails": {
"name": "Generate Array for Map",
"input": "{\n \"Comment\": \"Insert your JSON here\"\n}",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 3,
"previousEventId": 2,
"stateExitedEventDetails": {
"name": "Generate Array for Map",
"output": "[1,2,3,4,5]",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateEntered",
"id": 4,
"previousEventId": 3,
"stateEnteredEventDetails": {
"name": "Map",
"input": "[1,2,3,4,5]",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateStarted",
"id": 5,
"previousEventId": 4,
"mapStateStartedEventDetails": {
"length": 5
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 6,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 0
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 7,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 1
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 8,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 2
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 9,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 3
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 10,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 4
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 11,
"previousEventId": 6,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "1",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 12,
"previousEventId": 11,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":259}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 13,
"previousEventId": 12,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 0
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 14,
"previousEventId": 7,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "2",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 15,
"previousEventId": 14,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":776}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 16,
"previousEventId": 15,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 1
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 17,
"previousEventId": 8,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "3",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 18,
"previousEventId": 17,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":743}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 19,
"previousEventId": 18,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 2
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 20,
"previousEventId": 9,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "4",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 21,
"previousEventId": 20,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":790}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 22,
"previousEventId": 21,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 3
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 23,
"previousEventId": 10,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "5",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 24,
"previousEventId": 23,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":632}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 25,
"previousEventId": 24,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 4
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateSucceeded",
"id": 26,
"previousEventId": 25
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateExited",
"id": 27,
"previousEventId": 25,
"stateExitedEventDetails": {
"name": "Map",
"output": "[{\"Random Number\":259},{\"Random Number\":776},{\"Random Number\":743},{\"Random Number\":790},{\"Random Number\":632}]",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.745000-08:00",
"type": "ExecutionSucceeded",
"id": 28,
"previousEventId": 27,
"executionSucceededEventDetails": {
"output": "[{\"Random Number\":259},{\"Random Number\":776},{\"Random Number\":743},{\"Random Number\":790},{\"Random Number\":632}]",
"outputDetails": {
"truncated": false
}
}
}
]
}
Getting the error RangeError (end): Invalid value: Only valid value is 0: 1 when generating model when I try to generate model
Expected Behavior
when I use this command get generate model on match_details with assets/models/to_get/match_details.json
it should be creating a model inside the match_details folder with the fields inside the JSON file mentioned.
Current Behavior
When I try to do this I get the error RangeError (end): Invalid value: Only valid value is 0: 1 when generating model** when I try to generate model
Possible Solution
Am sure it is something about parsing the JSON file
More info
here is what the JSON file looks like
{
"success": true,
"details": {
"id": 22,
"date_time": "2022-04-12T20:00:00Z",
"home_team": {
"id": 69,
"home_strip": {
"id": 15,
"image": "/uploads/strip_5_0py3QXM.png"
},
"away_strip": {
"id": 16,
"image": "/uploads/WhatsApp_Image_2022-03-09_at_10.24.56_AM.jpeg"
},
"players": [{
"id": 47,
"is_cap": false,
"average_skill": 3,
"region": {
"id": 13,
"name_ar": "التجمع الخامس",
"name_en": "Fifth Settlement",
"state": {
"id": 8,
"name_ar": "القاهره",
"name_en": "Cairo"
}
},
"first_name": "Ezz El Din",
"last_name": "Karim",
"mobile": "01113481110",
"email": null,
"image": null,
"positions_ar": [{
"مدافع": 3
}],
"positions_en": [{
"CB": 3
}],
"basic_skills_ar": [{
"السرعة": 4
},
{
"تمرير الكرة": 3
},
{
"تسديد": 2
}
],
"basic_skills_en": [{
"speeding": 4
},
{
"Passing": 3
},
{
"shooting": 2
}
]
}],
"cap": {
"id": 46,
"is_cap": true,
"average_skill": 3,
"region": {
"id": 13,
"name_ar": "التجمع الخامس",
"name_en": "Fifth Settlement",
"state": {
"id": 8,
"name_ar": "القاهره",
"name_en": "Cairo"
}
},
"first_name": "Karim",
"last_name": "Garrana",
"mobile": "01113332257",
"email": "karim.garrana#gmail.com",
"image": null,
"positions_ar": [{
"مهاجم": 3
},
{
"مدافع": 4
}
],
"positions_en": [{
"ST": 3
},
{
"CB": 4
}
],
"basic_skills_ar": [{
"السرعة": 3
},
{
"تمرير الكرة": 3
},
{
"تسديد": 3
}
],
"basic_skills_en": [{
"speeding": 3
},
{
"Passing": 3
},
{
"shooting": 3
}
]
},
"average_skill": 3,
"points": 0,
"name": "كوبرا",
"league": 25,
"logo": "/uploads/9_IApeihR.png",
"region_ar": "التجمع الخامس",
"region_en": "Fifth Settlement"
},
"away_team": {
"id": 68,
"home_strip": {
"id": 14,
"image": "/uploads/strip_6.png"
},
"away_strip": {
"id": 13,
"image": "/uploads/strip_5.png"
},
"players": [{
"id": 46,
"is_cap": true,
"average_skill": 3,
"region": {
"id": 13,
"name_ar": "التجمع الخامس",
"name_en": "Fifth Settlement",
"state": {
"id": 8,
"name_ar": "القاهره",
"name_en": "Cairo"
}
},
"first_name": "Karim",
"last_name": "Garrana",
"mobile": "01113332257",
"email": "karim.garrana#gmail.com",
"image": null,
"positions_ar": [{
"مهاجم": 3
},
{
"مدافع": 4
}
],
"positions_en": [{
"ST": 3
},
{
"CB": 4
}
],
"basic_skills_ar": [{
"السرعة": 3
},
{
"تمرير الكرة": 3
},
{
"تسديد": 3
}
],
"basic_skills_en": [{
"speeding": 3
},
{
"Passing": 3
},
{
"shooting": 3
}
]
}],
"cap": {
"id": 45,
"is_cap": false,
"average_skill": 4,
"region": {
"id": 11,
"name_ar": "ميامى",
"name_en": "Miami",
"state": {
"id": 7,
"name_ar": "الإسكندرية",
"name_en": "Alexandria"
}
},
"first_name": "Ahmed",
"last_name": "Wagdi",
"mobile": "01207199086",
"email": "ahmed.w.amin#gmail.com",
"image": "/uploads/90f1e1c9-b430-4f9c-8347-a86be57f58676954964268664537546.jpg",
"positions_ar": [{
"مدافع": 5
}],
"positions_en": [{
"CB": 5
}],
"basic_skills_ar": [{
"تسديد": 5
},
{
"تمرير الكرة": 5
},
{
"السرعة": 5
}
],
"basic_skills_en": [{
"shooting": 5
},
{
"Passing": 5
},
{
"speeding": 5
}
]
},
"average_skill": 4,
"points": 2,
"name": "المنتقمون",
"league": 25,
"logo": "/uploads/6.png",
"region_ar": "التجمع الخامس",
"region_en": "Fifth Settlement"
},
"location": {
"id": 8,
"name_ar": "مدرسة الكابيتال",
"name_en": "Capital School",
"location": "30.014650515430546,31.4582347869873",
"region": 13
}
}
}
I want to get all the files from an assignment in Moodle. Is there a way to get all the files?
When I call core_course_get_contents from my local Moodle instance as
http://localhost:8077/webservice/rest/server.php?wstoken=11e2d8b7f8e21ca1804e41e9cac5a816&wsfunction=core_course_get_contents&courseid=4&moodlewsrestformat=json
I receive the response as:
[
{
"id": 22,
"name": "General",
"visible": 1,
"summary": "",
"summaryformat": 1,
"section": 0,
"hiddenbynumsections": 0,
"uservisible": true,
"modules": []
},
{
"id": 23,
"name": "Introduction",
"visible": 1,
"summary": "",
"summaryformat": 1,
"section": 1,
"hiddenbynumsections": 0,
"uservisible": true,
"modules": [
{
"id": 44,
"url": "http://localhost:8077/mod/assign/view.php?id=44",
"name": "Assignment",
"instance": 3,
"contextid": 99,
"visible": 1,
"uservisible": true,
"visibleoncoursepage": 1,
"modicon": "http://localhost:8077/theme/image.php/boost/assign/1613571924/icon",
"modname": "assign",
"modplural": "Assignments",
"indent": 0,
"onclick": "",
"afterlink": null,
"customdata": "\"\"",
"noviewlink": false,
"completion": 1,
"completiondata": {
"state": 0,
"timecompleted": 0,
"overrideby": null,
"valueused": false
}
},
{
"id": 46,
"url": "http://localhost:8077/mod/resource/view.php?id=46",
"name": "test(.txt)",
"instance": 24,
"contextid": 102,
"visible": 1,
"uservisible": true,
"visibleoncoursepage": 1,
"modicon": "http://localhost:8077/theme/image.php/boost/core/1613571924/f/text-24",
"modname": "resource",
"modplural": "Files",
"indent": 0,
"onclick": "",
"afterlink": null,
"customdata": "\"a:1:{s:10:\\\"printintro\\\";i:1;}\"",
"noviewlink": false,
"completion": 1,
"completiondata": {
"state": 0,
"timecompleted": 0,
"overrideby": null,
"valueused": false
},
"contents": [
{
"type": "file",
"filename": "test.txt",
"filepath": "/",
"filesize": 935,
"fileurl": "http://localhost:8077/webservice/pluginfile.php/102/mod_resource/content/1/test.txt?forcedownload=1",
"timecreated": 1621949734,
"timemodified": 1621949744,
"sortorder": 1,
"mimetype": "text/plain",
"isexternalfile": false,
"userid": 2,
"author": "ABC",
"license": "unknown"
}
],
"contentsinfo": {
"filescount": 1,
"filessize": 935,
"lastmodified": 1621949744,
"mimetypes": [
"text/plain"
],
"repositorytype": ""
}
}
]
}
]
I want to get the files from the assignment. Is there a way to achieve this?
Having the following record
{
"name": "
Festões Plástico, 12mt x 17cm - Festas Populares",
"categories": [
"Festas",
"Casamentos",
"Decorações"
],
"hierarchicalCategories": {
"lvl0": "Festas",
"lvl1": "Festas > Casamentos",
"lvl2": "Festas > Casamentos > Decorações"
},
"description": "",
"brand": "Misterius",
"price": 14.94,
"stock": "Disponível",
"prices": [
{
"value": 12,
"type": "specificValue",
"family": "fatos",
"subfamily": "example"
},
{
"value": 13,
"type": "specificValue13",
"family": "fatos13",
"subfamily": "example13"
},
{
"value": 14,
"type": "specificValue14",
"family": "fatos14",
"subfamily": "example14"
},
{
"value": 15,
"type": "specificValue15",
"family": "fatos15",
"subfamily": "example15"
},
{
"value": 16,
"type": "specificValue16",
"family": "fatos16",
"subfamily": "example16"
}
],
"color": [
{
"name": "Amarelo",
"label": "Amarelo,#FFFF00",
"hexa": "#FFFF00"
},
{
"name": "Azul",
"label": "Azul,#0000FF",
"hexa": "#0000FF"
},
{
"name": "Branco",
"label": "Branco,#FFFFFF",
"hexa": "#FFFFFF"
},
{
"name": "Laranja",
"label": "Laranja,#FFA500",
"hexa": "#FFA500"
},
{
"name": "Verde Escuro",
"label": "Verde Escuro,#006400",
"hexa": "#006400"
},
{
"name": "Vermelho",
"label": "Vermelho,#FF0000",
"hexa": "#FF0000"
}
],
"specialcategorie": "",
"reference": "3546",
"rating": 0,
"free_shipping": false,
"popularity": 0,
"objectID": "30"
}
Now by searching for "Festas Populares" will return the record and its attributes, is it possible to also filter for one attribute array as "prices" to only return one json. for example "prices.type"="specificValue14" and "family"="fatos14" and "family"="fatos" and "subfamily"="example"
{
“value”: 14,
“type”: “specificValue14”,
“family”: “fatos14”,
“subfamily”: “example14”
}
the record return would be:
{
"name": "
Festões Plástico, 12mt x 17cm - Festas Populares",
"categories": [
"Festas",
"Casamentos",
"Decorações"
],
"hierarchicalCategories": {
"lvl0": "Festas",
"lvl1": "Festas > Casamentos",
"lvl2": "Festas > Casamentos > Decorações"
},
"description": "",
"brand": "Misterius",
"price": 14.94,
"stock": "Disponível",
"prices": [
{
"value": 14,
"type": "specificValue14",
"family": "fatos14",
"subfamily": "example14"
}
],
"color": [
{
"name": "Amarelo",
"label": "Amarelo,#FFFF00",
"hexa": "#FFFF00"
},
{
"name": "Azul",
"label": "Azul,#0000FF",
"hexa": "#0000FF"
},
{
"name": "Branco",
"label": "Branco,#FFFFFF",
"hexa": "#FFFFFF"
},
{
"name": "Laranja",
"label": "Laranja,#FFA500",
"hexa": "#FFA500"
},
{
"name": "Verde Escuro",
"label": "Verde Escuro,#006400",
"hexa": "#006400"
},
{
"name": "Vermelho",
"label": "Vermelho,#FF0000",
"hexa": "#FF0000"
}
],
"specialcategorie": "",
"reference": "3546",
"rating": 0,
"free_shipping": false,
"popularity": 0,
"objectID": "30"
}
for some context a product can have multiple prices associated, for a specific user, or one day there is campaign giving discount, etc so for that cases want to filter price associated to the product/record.
No, this is not possible with Algolia. Records are always returned with the attributes specified inside attributesToRetrieve. These attributes are returned in full.