Workload optimisation for AI image generation APP

Hi😃

I have an AI image generation app where I make an API call and get a webhook back with image URL.

This is how my APP is set up right now:

  1. After clicking the button ā€œgenerateā€ a new ā€œimage_genā€ thing is created with ID that is retrived after making the API call.
  2. When the APP receives the webhook new ā€œLogā€ thing is created with image URL and ID.
  3. After the ā€œLogā€ is created the next step is to make changes to the correct ā€œimage_genā€ thing updating image URL field. (ā€œimage_genā€ now has a user in ā€œcreated byā€ field) and at last custom state is updated with the ID
  4. Image is diplayed by searching for the correct ā€œimage_genā€ ID
  5. Now user has to click ā€œadd to libraryā€ to add image URL to his ā€œgenerated imagesā€ list (field in User: list of images)

When I want to display all images generated by a user in ā€œLibraryā€ in a repeating group the fields are set to:
Screenshot 2024-09-20 at 20.01.16

I am wondering if this is way of storing and displaying images is efficient?
or would it be better if instead of saving image URLs to a field in User (list of images) to save it as list of ā€œimage_genā€. But this means I would have to display images in a repeating group by doing a search which I consumes a lot of workload units.
Screenshot 2024-09-20 at 20.10.36

I hope this makes sensešŸ˜