| 146 | * @param {number} avgRating: # of stars given to the restaurant |
| 147 | */ |
| 148 | const addMockRating = async (restaurantId, avgRating) => { |
| 149 | // Create new `rating` obj |
| 150 | const newRating = { |
| 151 | rating: avgRating, |
| 152 | text: data.ratingsTexts[avgRating], |
| 153 | userName: 'Anonymous (Bot)', |
| 154 | }; |
| 155 | |
| 156 | // Add new rating to given restaurant's `ratings/` subcollection |
| 157 | await addDoc( |
| 158 | collection(db, `restaurants/${restaurantId}/ratings`), |
| 159 | newRating |
| 160 | ); |
| 161 | }; |
| 162 | |
| 163 | const main = async () => { |
| 164 | // Connect to emulators if a `demo` environment is pulled |