Create a list of things using 'for' loop

tl;dr: Newbie-me created a really dumb data structure and I need help consolidating 3 lists of things into 1 new list of things.

I’ll lead off by saying that this is embarrassing.

Back when I was first creating the MVP for my idea, I didn’t know much about data structure and whatnot, so I painted myself into the following tech-debt corner, which is getting in the way of other features I want to implement:

I have a service-based marketplace centered around painting plastic miniatures. It’s basically UpWork, but for painting miniatures in a specific gaming community. The jobs are structured using 3 things:

  1. availableJob - This is created when a user creates a new job for painters to bid on.
  2. openJob - When a client accepts a bid from a painter, this is created and the associated availableJob is deleted.
  3. completedJob - When a job is finished and paid for, the openJob is deleted and a completedJob is created.

Rather than having one thing that follows a commission from cradle to grave, I’ve got 3 things that are created and deleted based on what stage the job is in. This is having a negative impact on SEO (dead links to non-existent openJobs) and has put a damper on what other features I can implement. While the above worst-practice example of schema has been a fantastic learning experience in what not to do, it has officially gotten to the point where it is in the way.

I am now attempting to consolidate these three things into a single thing, commission, which will have a status field (available, active, or closed) indicating which stage the job is at, rather than have three separate things (like newbie-me created).

Between the three lists of things, I have a few hundred new commission things to create, but I can’t get my mind around how to create a tool to do this in one fell swoop. I basically want to create a for loop that creates a new commission (and populates certain fields) for each avialableJob, openJob, and completedJob.

I’m not sure how to tackle this on Bubble other than to create repeating groups of the 3 lists and put a make new commission button in each cell, then do them one-by-one (which sounds terrible).

Any assistance is greatly appreciated. Thanks!

1 Like

Hey @nnich19 :slight_smile: I’m not 100% sure but it sounds like it would be best to set up an admin page (since you’ll be modifying live data) and use three API workflows in order to create a new Commission for each of the jobs in the database

This way, there would be three API workflows that would run on three lists of things (Search for AvailableJobs, Search for OpenJobs, and Search for CompletedJobs being the lists). The action of that API would Create a New Commission, using the data from each old AvailableJobs, OpenJobs, and CompletedJobs.

For example, if you had 100 AvailableJobs, 100 OpenJobs, and 100 Completed Jobs, running those three API workflows on each of those lists would create 300 Commissions total. If you are using the “Created By” field for the old types, you would probably also need to add an Owner field (Type: User, List: No) to the Commission Type since the Created By field will be associated with your admin User account (I think!).

Let me know if you need help setting this up, if you’d like to PM me or add me as a collaborator for the workflows.

Also, nothing to be embarrassed about! It definitely sounds like you’ve got an awesome app that people are using! Congrats!! :slight_smile: