Refactor catalog to use coordinate-based GraphQL endpoints
All checks were successful
Build Docker Image / build (push) Successful in 3m33s
All checks were successful
Build Docker Image / build (push) Successful in 3m33s
Replace entity-specific queries (GetProductsNearHub, GetOffersByHub, GetHubsForProduct, GetSuppliersForProduct) with unified coordinate-based endpoints (NearestHubs, NearestOffers, NearestSuppliers, RouteToCoordinate). This simplifies backend architecture from 18 to 8 core endpoints while maintaining identical UI/UX behavior. All composables and pages now use coordinates + client-side grouping instead of specialized backend queries. For global product filtering, uses center point (0,0) with 20000km radius. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { GetSupplierProfilesDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
import { GetSuppliersForProductDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { NearestSuppliersDocument } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
const PAGE_SIZE = 24
|
||||
|
||||
@@ -24,29 +24,22 @@ export function useCatalogSuppliers() {
|
||||
const fetchPage = async (offset: number, replace = false) => {
|
||||
if (replace) isLoading.value = true
|
||||
try {
|
||||
// If filtering by product, use specialized query
|
||||
// If filtering by product, use nearestSuppliers with global search
|
||||
// (center point 0,0 with very large radius to cover entire globe)
|
||||
if (filterProductUuid.value) {
|
||||
const data = await execute(
|
||||
GetSuppliersForProductDocument,
|
||||
{ productUuid: filterProductUuid.value },
|
||||
NearestSuppliersDocument,
|
||||
{
|
||||
lat: 0,
|
||||
lon: 0,
|
||||
radius: 20000, // 20000 km radius covers entire Earth
|
||||
productUuid: filterProductUuid.value,
|
||||
limit: 500 // Increased limit for global search
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
const supplierUuids = (data?.suppliersForProduct || []).map(s => s?.uuid).filter(Boolean)
|
||||
// Fetch full profiles for these suppliers
|
||||
if (supplierUuids.length > 0) {
|
||||
const profilesData = await execute(
|
||||
GetSupplierProfilesDocument,
|
||||
{ limit: supplierUuids.length, offset: 0 },
|
||||
'public',
|
||||
'exchange'
|
||||
)
|
||||
// Filter to only include suppliers that match the product filter
|
||||
const allProfiles = profilesData?.getSupplierProfiles || []
|
||||
items.value = allProfiles.filter(p => supplierUuids.includes(p.uuid))
|
||||
} else {
|
||||
items.value = []
|
||||
}
|
||||
items.value = data?.nearestSuppliers || []
|
||||
total.value = items.value.length
|
||||
isInitialized.value = true
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user