mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 14:11:13 -05:00
Optimize select queries
This commit is contained in:
@@ -61,7 +61,7 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
||||
const loadInitialLocation = async (locationId: string) => {
|
||||
const { data, error } = await supabase
|
||||
.from('locations')
|
||||
.select('*')
|
||||
.select('id, name, city, state_province, country, postal_code, latitude, longitude, timezone')
|
||||
.eq('id', locationId)
|
||||
.maybeSingle();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export function SearchResults({ query, onClose }: SearchResultsProps) {
|
||||
// Search companies
|
||||
const { data: companies } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.select('id, name, slug, description, company_type, logo_url, average_rating, review_count')
|
||||
.or(`name.ilike.${searchTerm},description.ilike.${searchTerm}`)
|
||||
.limit(3);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
||||
try {
|
||||
const { data: slaData } = await supabase
|
||||
.from('moderation_sla_metrics')
|
||||
.select('*');
|
||||
.select('pending_count, avg_wait_hours');
|
||||
|
||||
const { count: assignedCount } = await supabase
|
||||
.from('content_submissions')
|
||||
@@ -302,7 +302,7 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
||||
// Get submission details FIRST for better toast message
|
||||
const { data: submission } = await supabase
|
||||
.from('content_submissions')
|
||||
.select('submission_type')
|
||||
.select('id, submission_type')
|
||||
.eq('id', submissionId)
|
||||
.single();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export function useProfile(userId: string | undefined) {
|
||||
if (profileData.location_id) {
|
||||
const { data: location } = await supabase
|
||||
.from('locations')
|
||||
.select('*')
|
||||
.select('id, name, city, state_province, country, timezone')
|
||||
.eq('id', profileData.location_id)
|
||||
.single();
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ export function useSearch(options: UseSearchOptions = {}) {
|
||||
if (types.includes('company')) {
|
||||
const { data: companies } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.select('id, name, slug, description, company_type, logo_url, average_rating, review_count')
|
||||
.or(`name.ilike.%${searchQuery}%,description.ilike.%${searchQuery}%`)
|
||||
.limit(Math.ceil(limit / types.length));
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function submitCompanyCreation(
|
||||
},
|
||||
status: 'pending' as const
|
||||
})
|
||||
.select()
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
@@ -81,7 +81,7 @@ export async function submitCompanyUpdate(
|
||||
// Fetch existing company data (all fields for original_data)
|
||||
const { data: existingCompany, error: fetchError } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.select('id, name, slug, description, company_type, person_type, logo_url, card_image_url, banner_image_url, banner_image_id, card_image_id, headquarters_location, website_url, founded_year, founded_date, founded_date_precision')
|
||||
.eq('id', companyId)
|
||||
.single();
|
||||
|
||||
@@ -120,7 +120,7 @@ export async function submitCompanyUpdate(
|
||||
},
|
||||
status: 'pending' as const
|
||||
})
|
||||
.select()
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
|
||||
@@ -207,7 +207,7 @@ export async function submitParkCreation(
|
||||
},
|
||||
status: 'pending' as const
|
||||
})
|
||||
.select()
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
@@ -260,7 +260,7 @@ export async function submitParkUpdate(
|
||||
// Fetch existing park data first
|
||||
const { data: existingPark, error: fetchError } = await supabase
|
||||
.from('parks')
|
||||
.select('*')
|
||||
.select('id, name, slug, description, park_type, status, opening_date, opening_date_precision, closing_date, closing_date_precision, website_url, phone, email, location_id, operator_id, property_owner_id, banner_image_url, banner_image_id, card_image_url, card_image_id')
|
||||
.eq('id', parkId)
|
||||
.single();
|
||||
|
||||
@@ -299,7 +299,7 @@ export async function submitParkUpdate(
|
||||
},
|
||||
status: 'pending' as const
|
||||
})
|
||||
.select()
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
@@ -379,7 +379,7 @@ export async function submitRideCreation(
|
||||
},
|
||||
status: 'pending' as const
|
||||
})
|
||||
.select()
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function Designers() {
|
||||
try {
|
||||
let query = supabase
|
||||
.from('companies')
|
||||
.select('*');
|
||||
.select('id, name, slug, description, company_type, person_type, logo_url, card_image_url, headquarters_location, founded_year, founded_date, founded_date_precision, average_rating, review_count');
|
||||
|
||||
// Filter only designers
|
||||
query = query.eq('company_type', 'designer');
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function Manufacturers() {
|
||||
try {
|
||||
let query = supabase
|
||||
.from('companies')
|
||||
.select('*');
|
||||
.select('id, name, slug, description, company_type, person_type, logo_url, card_image_url, headquarters_location, founded_year, founded_date, founded_date_precision, average_rating, review_count');
|
||||
|
||||
// Filter only manufacturers
|
||||
query = query.eq('company_type', 'manufacturer');
|
||||
|
||||
Reference in New Issue
Block a user