09-26-2013 10:29 AM - edited 09-26-2013 10:30 AM
I'm using 11.52 patch 1 web protocol
I need to grab pictures of a random customer's puchases. Some customers have zero on record purchases, some customers purchase hundreds of items. When the browser requests these pictures, it does so in at the same time (i.e. a web concurrent request).
Any tips on how I can create simulataneous requests of n number of pictures? Obviously, I can easily correlate the pictures I'm being sent and put them into a for loop to grab every one of them but that doesn't account for concurrency.
I'm hoping there's a function call I'm not aware of that makes this kind of thing nice and easy. Otherwise, I suppose I might be able construct an eloborate web_custom_request (or series of requests), but it seems like there should be a good way to do this kind of thing.
09-26-2013 02:46 PM
I dont really understand your goal, but yes you can do it using the function web_concurrent_start, then after this add all the calls or functions to get the pictures and then add web_concurrent_end, what ever is between web_concurrent_start and web_concurrent_end will be executed simultaneously.
Check on function reference for additional details.
hope this helps
09-26-2013 03:40 PM
Thank you for your response. Sorry, maybe I could've been clearer. I'm aware of the web_concurrent_start and web_concurrent_end functions. What I need is to have a dynamic number of calls within the that call.
Customer 1 has bought four items.
picture 1 (item a)
picture 2 (item b)
picture 3 (item c)
picture 4 (item d)
--- iteration ends, new customer
Customer 2 has bought two items.
picture 1 (item e)
picture 2 (item f)
--- iteration ends, new customer
Customer 3 has bought six items.
picture 1 (item g)
picture 2 (item h)
picture 3 (item i)
picture 4 (item j)
picture 5 (item k)
picture 6 (item l)
How can I get a variable number of requests sent within a web_concurrent_start block?
09-26-2013 09:37 PM
ok I got the idea, I would need to know more and see one script to give someting more specific but here is my idea.
Lets say there is a maximum of 10 pictures you will need, all the uses will purchase 10 articles or less, so you create inside the web_concurrent block the 10 requests for getting 10 pictures, each request will evaluate using a If statement if there is need for that picture or not, since you know how many itemd each user got you simply parametize that part, in example, user AAAA purchased 7 items, so you paramtetrize the user name and the 10 picture names, but the last 3 pictures will be called 0000.jpg in the parameter value, so the if will evaluate if the name is or not 0000.jpg before execute the statement to call the picture, not sure if you get the idea.
maybe if you share more details about the info you will have in advance, and how the function that call those pictures looks like and the picture name format or something that helps to understand better how far we can get using custom code.
09-27-2013 07:21 AM
Thank you for the response. I was thinking of the same approach but there can be hundreds of pictures or zero pictures, so I'd have to create hundreds of (usually unused) web requests to accomodate this kind of thing. The programmer in me sees this kind of approach as less than great, but I suppose I'll have to deal with it.
I'll give this some more thought and research and post here if I come up with a good solution.
09-27-2013 11:11 AM
09-27-2013 10:41 PM
It's just a simple web_url call