Remove mock seed drivers and dead marker scatter
The drivers table was seeded with 4 fake fixtures (Karim/Rana/Omar/Layal) using randomuser.me/unsplash placeholder images. They had no user_id, no position, and were excluded from matching and the rider map by design, so they only ever cluttered the dashboard. The table now starts empty — real drivers are created in-app via onboarding (driver/profile POST), which links a row to a real user account and gives it a live GPS position. Dropped the dead random-offset scatter in generateMarkersFromData that fabricated fake driver positions for drivers without GPS. It was already unreachable (the null-position filter excluded those drivers), so this is stub cleanup, not a behavior change — drivers without a real position simply aren't rendered. The 4 fixture rows were also removed from the live Neon DB (user_id IS NULL); real onboarded drivers were untouched. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+7
-20
@@ -4,13 +4,11 @@ import type { Driver, MarkerData } from "@/types/type";
|
||||
|
||||
const directionsAPI = process.env.EXPO_PUBLIC_GOOGLE_API_KEY;
|
||||
|
||||
// Build map markers from driver rows. Drivers with a real GPS position use it
|
||||
// directly; only legacy seed rows (no position) fall back to a small random
|
||||
// scatter around the rider so the map isn't empty during local dev.
|
||||
// Build map markers from driver rows. Only drivers reporting a real GPS
|
||||
// position are shown — there is no fallback/scatter, so drivers without a
|
||||
// position (none, now that seed fixtures are gone) simply aren't rendered.
|
||||
export const generateMarkersFromData = ({
|
||||
data,
|
||||
userLatitude,
|
||||
userLongitude,
|
||||
}: {
|
||||
data: Driver[];
|
||||
userLatitude: number;
|
||||
@@ -18,23 +16,12 @@ export const generateMarkersFromData = ({
|
||||
}): MarkerData[] => {
|
||||
return data
|
||||
.filter((driver) => driver.latitude != null && driver.longitude != null)
|
||||
.map((driver) => {
|
||||
const lat =
|
||||
driver.latitude != null
|
||||
? driver.latitude
|
||||
: userLatitude + (Math.random() - 0.5) * 0.01;
|
||||
const lng =
|
||||
driver.longitude != null
|
||||
? driver.longitude
|
||||
: userLongitude + (Math.random() - 0.5) * 0.01;
|
||||
|
||||
return {
|
||||
.map((driver) => ({
|
||||
...driver,
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
latitude: driver.latitude as number,
|
||||
longitude: driver.longitude as number,
|
||||
title: `${driver.first_name} ${driver.last_name}`,
|
||||
};
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
export const calculateRegion = ({
|
||||
|
||||
+3
-14
@@ -194,20 +194,9 @@ await sql`CREATE TABLE IF NOT EXISTS ride_offers (
|
||||
await sql`CREATE INDEX IF NOT EXISTS ride_offers_driver_status_idx ON ride_offers(driver_id, status)`;
|
||||
await sql`CREATE INDEX IF NOT EXISTS ride_offers_ride_idx ON ride_offers(ride_id)`;
|
||||
|
||||
const count = await sql`SELECT COUNT(*)::int AS n FROM drivers`;
|
||||
if (count[0].n === 0) {
|
||||
await sql`INSERT INTO drivers
|
||||
(first_name, last_name, profile_image_url, car_image_url, car_seats, rating, service)
|
||||
VALUES
|
||||
('Karim', 'Haddad', 'https://randomuser.me/api/portraits/men/32.jpg', 'https://images.unsplash.com/photo-1555215695-3004980ad54e?w=600', 4, 4.8, 'car'),
|
||||
('Rana', 'Khalil', 'https://randomuser.me/api/portraits/women/44.jpg', 'https://images.unsplash.com/photo-1552519507-da3b142c6e3d?w=600', 1, 4.9, 'moto'),
|
||||
('Omar', 'Chehab', 'https://randomuser.me/api/portraits/men/75.jpg', 'https://images.unsplash.com/photo-1580273916550-e323be2ae537?w=600', 4, 4.6, 'car'),
|
||||
('Layal', 'Abou-Jaoude', 'https://randomuser.me/api/portraits/women/68.jpg', 'https://images.unsplash.com/photo-1590362891991-f776e747a588?w=600', 2, 4.7, 'courier')`;
|
||||
console.log("Seeded 4 drivers.");
|
||||
} else {
|
||||
console.log(`Drivers table already has ${count[0].n} rows, skipping seed.`);
|
||||
}
|
||||
|
||||
// No seed drivers: the drivers table starts empty. Real drivers are created
|
||||
// in-app via onboarding (driver/profile POST), which links a drivers row to a
|
||||
// real user account and gives it a live GPS position for matching.
|
||||
console.log("Database ready.");
|
||||
|
||||
await pool.end();
|
||||
|
||||
Reference in New Issue
Block a user