perf: complete performance audit optimizations
This commit is contained in:
@ -5,14 +5,14 @@ import type { BusStop, Route } from '@/types'
|
||||
export const busStopsService = {
|
||||
/** Get all bus stops */
|
||||
async getAllBusStops(): Promise<BusStop[]> {
|
||||
const { data, error } = await supabase.from('bus_stops').select('*')
|
||||
const { data, error } = await supabase.from('bus_stops').select('id, name, latitude, longitude, city, address, parent_id, side, stop_type, has_shelter, has_seating, is_accessible, created_at, updated_at')
|
||||
if (error) throw new Error(error.message)
|
||||
return data as BusStop[]
|
||||
},
|
||||
|
||||
/** Get a single bus stop by ID */
|
||||
async getBusStopById(id: string): Promise<BusStop> {
|
||||
const { data, error } = await supabase.from('bus_stops').select('*').eq('id', id).single()
|
||||
const { data, error } = await supabase.from('bus_stops').select('id, name, latitude, longitude, city, address, parent_id, side, stop_type, has_shelter, has_seating, is_accessible, created_at, updated_at').eq('id', id).single()
|
||||
if (error) throw new Error(error.message)
|
||||
return data as BusStop
|
||||
},
|
||||
|
||||
@ -18,14 +18,14 @@ export const businessService = {
|
||||
|
||||
/** Get all businesses */
|
||||
async getAllBusinesses(): Promise<Business[]> {
|
||||
const { data, error } = await supabase.from('businesses').select('*')
|
||||
const { data, error } = await supabase.from('businesses').select('id, name, address, phone, image_url, social_media, category, latitude, longitude, area, updated_at')
|
||||
if (error) throw new Error(error.message)
|
||||
return data as Business[]
|
||||
},
|
||||
|
||||
/** Get a single business by ID */
|
||||
async getBusiness(id: string): Promise<Business> {
|
||||
const { data, error } = await supabase.from('businesses').select('*').eq('id', id).single()
|
||||
const { data, error } = await supabase.from('businesses').select('id, name, address, phone, image_url, social_media, category, latitude, longitude, area, updated_at').eq('id', id).single()
|
||||
if (error) throw new Error(error.message)
|
||||
return data as Business
|
||||
},
|
||||
|
||||
@ -5,7 +5,7 @@ import type { Route, BusStop } from '@/types'
|
||||
export const routesService = {
|
||||
/** Get all routes with optional filtering */
|
||||
async getAllRoutes(filters?: { originCity?: string, destinationCity?: string }): Promise<Route[]> {
|
||||
let query = supabase.from('routes').select('*')
|
||||
let query = supabase.from('routes').select('id, name, description, color, direction, origin_city, destination_city, distance_km, estimated_duration_minutes, average_speed_kmh, status, created_at, updated_at')
|
||||
|
||||
if (filters?.originCity) {
|
||||
query = query.eq('origin_city', filters.originCity)
|
||||
@ -21,7 +21,7 @@ export const routesService = {
|
||||
|
||||
/** Get a single route by ID */
|
||||
async getRouteById(id: string): Promise<Route> {
|
||||
const { data, error } = await supabase.from('routes').select('*').eq('id', id).single()
|
||||
const { data, error } = await supabase.from('routes').select('id, name, description, color, direction, origin_city, destination_city, distance_km, estimated_duration_minutes, average_speed_kmh, status, created_at, updated_at').eq('id', id).single()
|
||||
if (error) throw new Error(error.message)
|
||||
return data as Route
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user