Back in May, I showed How to get AI to tell you the flavor of the day at Kopp’s, and in the demo, I showed how you can populate a Chroma DB vector database using an API that I found on the Kopp’s website. That is cool, but Kopp’s isn’t the only custard shop in the area. Today, I want to look at how to get the flavor of the day for Culver’s programmatically, and then we are going to merge the data to start a unified custard dataset. Let’s start with the Kopps’s data. For today’s demo, we are going to be using Vue.js and the Composition API (because I miss it more than I can express).
See the Pen
Kopp's Flavor Forecast by Joe Steinbring (@steinbring)
on CodePen.
So, what is going on above?
- onMounted(), the app is running fetchFlavors() which makes an API call to https://kopps.com/wp-json/kopps/flavor-preview and sets the value of flavors.value to what comes back.
- The template uses a simple v-for loop to iterate over the data.
- The date column uses new Date().toLocaleDateString() to give you a more readable date value.
I don’t know about you but that Bienenstichkuchen on the 27th sounds amazing to me.
For Culver’s, we can do something similar. Using the API for getting the nearest locations, you can get what today’s “flavor of the day” is for that location.
See the Pen
Culver's "Flavor of the Day" by Joe Steinbring (@steinbring)
on CodePen.
You might notice a problem with the Culver’s example, though. They are using CORS to protect their API (as they should). You can use a browser extension or a proxy to add CORS headers but this app won’t work by default.
So, how do we get it to work? If we create a CloudFlare Workers script that gets the same data and then returns it to the user as JSON, we can simplify the data that is returned and add CORS headers. Let’s see what the result looks like.
See the Pen
Culver's "Flavor of the Day" v2 by Joe Steinbring (@steinbring)
on CodePen.
So, what’s going on above?
- onMounted(), the app is running fetchLocations() which makes an API call to https://culvers-fotd.joe.workers.dev and sets the value of locations.value to what comes back.
- The template uses a simple v-for loop to iterate over the data.
The result is a list of Culver’s locations near Milwaukee and the flavor of the day at each one.
The next step is to merge the Kopp’s data with the Culver’s data but the datasets have a lot of differences. The Kopp’s data is a flavor forecast while the Culver’s data only covers today’s flavors of the day. Also, there is a different flavor of the day per Culver’s location where it is the same flavors at all three Kopp’s locations (Greenfield, Brookfield, and Glendale).
Let’s take a look at the unified listing of today’s flavors.
See the Pen
Culver's "Flavor of the Day" v2 by Joe Steinbring (@steinbring)
on CodePen.
So, what’s going on above?
- The kopps variable holds the Kopp’s flavor data and the culvers variable holds the Culver’s flavor data.
- fetchKopps() gets the Kopp’s data from the API and fetchCulvers() gets the Culver’s data from it’s API.
- There is a combinedData computed property that combines the two datasets into one and then sorts it by what city the location is in.
So, what’s next? Milwaukee has many more custard locations than those two (Gilles, Murfs, Kraverz, Kitt’s, etc). For the most part, to get flavor data from those sites, you would need to screen scrap. We recently looked at How to use AI to make web scraping easier, so we do have a mold for dealing with the issue.
Stay tuned for “Part Two”.
https://jws.news/2024/let-play-with-some-milwaukee-custard-data/