jwcha1030 / CS416_GroupProject

2 stars 1 forks source link

addListCollectionItemCatalogDisplayImages & editAllCollectionItemCatalogDisplayImage rescode #22

Open jwcha1030 opened 3 years ago

jwcha1030 commented 3 years ago

Rescode=0 error occurs when I upload more than 35 images at once via either of the two API calls.

Test with 35 images: SUCCESS

Screen Shot 2021-01-08 at 12 36 55 AM

Test with 36 images or above: Fail

Habced commented 3 years ago

still testing. if i don't update in a couple days make sure to ask what the status is

jwcha1030 commented 3 years ago

if uploading more than 40 images at a time is an issue, I'll try submitting in smaller numbers multiple times. Lemme know your decision.

Habced commented 3 years ago

Heroku has a 30 second timeout that I can't change. It seems like you'll have to split up the call. You could try calling "editAll" for the first 15 images, and then call "addList" for the rest of the images 15 at a time

(the num_of_files for the first editAll should match the number of images that you are sending in that specific api call not the total images)

jwcha1030 commented 3 years ago

I haven't implemented split up calls on "editAll", but I did on the "addAll" with a limit of 15 images per API call. I get a rescode 0 error.

Implementation and test is done as follows:

  1. Admin adds more than 15 images ( say 17 images) at once to a new item (i.e., that has no catalog images; thus cd_id=-1).
  2. Then handleAddCatalogSubmit() in Figure 1 will split up the calls twice. The first call will submit (via addCatalogPost() in Figure 2) the first 15 images, and the remaining two images will be submitted next.
  3. Rescode=0 error occurs on the second API call.

Question: Do consecutive "addListCollectionItemCatalogDisplayImages API call" append images to the prior calls in the db?

Figure 1: Function that split up API calls based on maxImagesPerPost=15

Screen Shot 2021-01-16 at 1 17 07 AM

Figure 2: Function that calls addListCollectionItemCatalogDisplayImages API

Screen Shot 2021-01-16 at 1 20 32 AM
Habced commented 3 years ago

for add list, index always starts at 0 and will append to the end of the list of current catalogdisplayimages

jwcha1030 commented 3 years ago

then, should consecutive calls of addList work as it should in editList? I get rescode error for unknown reason

jwcha1030 commented 3 years ago

AddList call bug:

Test1

  1. Total 10 images are uploaded with a maximum of 5 images per API call (i.e., AddList call).
  2. Two consecutive "AddList" will be called. First 5 images, then the next 5 images.
  3. Result: Rescode=0 on the second call. First 5 images are uploaded with a sucess.
  4. Inputs and the result shown below: Screen Shot 2021-01-16 at 11 24 58 PM

Test2

  1. Total 13 images are uploaded with a maximum of 5 images per API call.
  2. Three consecutive "AddList" will be called. First 5 images, second 5 images, and the third 3 images.
  3. Result: Rescode=0 on the second and the third call. First call returns a success.
  4. Inputs and the result shown below: Screen Shot 2021-01-16 at 11 32 41 PM
jwcha1030 commented 3 years ago

UPDATE: AddList works in terms of uploading images. BUT, the upload is not in order due to asynchronous uploads.

Tested out editAll, addList call returns rescode=0.

Process (tested out with max 5 images per call):

  1. An item originally has 7 images saved.
  2. EditAll submitted after adding 2 more images.
  3. First editAll API is called to submit 5 images.
  4. Next addList API is called to submit the other 4 images.
  5. AddList returns rescode=0. Thus, only images submitted by editAll call is visible.

*Note that addList input is from index=0.

Screen Shot 2021-01-18 at 7 11 24 PM