Hi Everyone!
Can you help point me in the right direction to help solve for my use case below?
Any examples of scripts are much appreciated!
Use case:
Create a simple matching script that will take inputs from a form and then return a list of matches based on the inputs
Below is a (slightly) simplified version of my use case.
Goal: to match people with specific types of food based on their allergies and taste preferences for a wedding.
Data:
Table 1. Food List. This includes Information about certain types of food. Each record includes a food choice with the feature “allergies” and the feature “food preference”.
Feature: “Allergies”
Allowed Values: “peanut”, “gluten”, “dairy”
Many to Many relationship
One person may have multiple allergies and one allergy may exist for multiple people
Feature: “Preference”
Allowed Values: “kosher”, “vegetarian”, “vegan”
1 to Many relationship
Each person can only select one preference. One preference may be true for many people.
Table 2. Customer request. This includes the food preferences for each customer. The food preferences are displayed as an array of values that are linked to the tables below.
Table 3. "food preferences"
Table 4. "allergies"
Table links: the features in tables 3 and 4 are linked to tables 1. and 2. and appear in tables 1 and 2 as an array.
Desired Workflow:
- A user fills out a form listing their allergies (up to 3 in total) and their preference (only 1 allowed).
- These values populate as a row in the table “customer request”
- A list is provided of all the food options that satisfy both their allergy criteria and food preference criteria. There may be up to ~20 choices.
- The food choice options are stored in the table “customer request”
- An email is sent to the person who submitted their information in the form with a list of their food matches.
As I understand it the script needs to,
- Provide a list of all records in the table “Food List”
- Then, for each record in table “Customer Request”, find the value located in the preference column and filter the original list of foods to show only the foods that match this preference.
- Then, for each record in table “Customer Request”, find the value located in the allergy column and filter the original list of foods to show only the foods that match this allergy preference.
- Display this list
There are multiple ways to accomplish this. I would definitely encourage people to let me know if there is a better way to approach this problem in order to make the most eloquent script possible. This will eventually be used to process ~100 match requests a day and thus the number of records will grow quickly.
Thank you!