| | 1238 | -- =========================================================== |
| | 1239 | -- FLOW 5: ACCEPTED / IN_PROGRESS rides |
| | 1240 | -- Poraki: 1→2→4 |
| | 1241 | -- Voznjata e vo tek, nema kraj i plakjanje uste |
| | 1242 | -- =========================================================== |
| | 1243 | FOR b IN 1..batches LOOP |
| | 1244 | INSERT INTO Notifications (message_id, sent_time, user_id, ride_id, status_id) |
| | 1245 | SELECT * FROM ( |
| | 1246 | |
| | 1247 | -- Poraka 1: Baranjeto isprateno → request_time |
| | 1248 | SELECT mid_1, r.request_time, r.user_id, r.ride_id, sid_notif_sent |
| | 1249 | FROM Rides r |
| | 1250 | WHERE r.ride_id BETWEEN (b-1)*batch_size+1 AND b*batch_size |
| | 1251 | AND r.status_id IN (rid_accepted, rid_in_progress) |
| | 1252 | |
| | 1253 | UNION ALL |
| | 1254 | |
| | 1255 | -- Poraka 2: Vozacot prifati → pickup_time |
| | 1256 | SELECT mid_2, r.pickup_time, r.user_id, r.ride_id, sid_notif_sent |
| | 1257 | FROM Rides r |
| | 1258 | WHERE r.ride_id BETWEEN (b-1)*batch_size+1 AND b*batch_size |
| | 1259 | AND r.status_id IN (rid_accepted, rid_in_progress) |
| | 1260 | |
| | 1261 | UNION ALL |
| | 1262 | |
| | 1263 | -- Poraka 4: Vozacot pristigna → start_time |
| | 1264 | SELECT mid_4, r.start_time, r.user_id, r.ride_id, sid_notif_sent |
| | 1265 | FROM Rides r |
| | 1266 | WHERE r.ride_id BETWEEN (b-1)*batch_size+1 AND b*batch_size |
| | 1267 | AND r.status_id IN (rid_accepted, rid_in_progress) |
| | 1268 | |
| | 1269 | ) flows; |
| | 1270 | |
| | 1271 | RAISE NOTICE '[ACCEPTED/IN_PROGRESS] Batch % / %', b, batches; |
| | 1272 | END LOOP; |
| | 1273 | |
| | 1274 | -- =========================================================== |
| | 1275 | -- FLOW 6: REQUESTED rides |
| | 1276 | -- Poraka: samo 1 |
| | 1277 | -- Barano no vozac uste ne odgovoril |
| | 1278 | -- =========================================================== |
| | 1279 | FOR b IN 1..batches LOOP |
| | 1280 | INSERT INTO Notifications (message_id, sent_time, user_id, ride_id, status_id) |
| | 1281 | |
| | 1282 | -- Poraka 1: Baranjeto isprateno → request_time |
| | 1283 | SELECT mid_1, r.request_time, r.user_id, r.ride_id, sid_notif_sent |
| | 1284 | FROM Rides r |
| | 1285 | WHERE r.ride_id BETWEEN (b-1)*batch_size+1 AND b*batch_size |
| | 1286 | AND r.status_id = rid_requested; |
| | 1287 | |
| | 1288 | RAISE NOTICE '[REQUESTED] Batch % / %', b, batches; |
| | 1289 | END LOOP; |