Simplify GEO API - use new list endpoints and routes in nearestOffers
All checks were successful
Build Docker Image / build (push) Successful in 4m11s
All checks were successful
Build Docker Image / build (push) Successful in 4m11s
- Replace GetNodesDocument with HubsListDocument in useCatalogHubs.ts - Replace GetSupplierProfilesDocument with SuppliersListDocument in useCatalogSuppliers.ts - Replace manual grouping with ProductsListDocument in useCatalogProducts.ts - Update nearestOffers to pass hubUuid for server-side route calculation - Remove RouteToCoordinate calls - routes now included in nearestOffers response - Delete 15 obsolete GraphQL files - Add 3 new list endpoints: HubsList, SuppliersList, ProductsList - Fix TypeScript errors in CalcResultContent, LocationsContent, hubs page, location store
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { GetSupplierProfilesDocument } from '~/composables/graphql/public/exchange-generated'
|
||||
import { NearestSuppliersDocument } from '~/composables/graphql/public/geo-generated'
|
||||
import { SuppliersListDocument, NearestSuppliersDocument } from '~/composables/graphql/public/geo-generated'
|
||||
|
||||
const PAGE_SIZE = 24
|
||||
|
||||
@@ -45,40 +44,22 @@ export function useCatalogSuppliers() {
|
||||
return
|
||||
}
|
||||
|
||||
// Default: fetch all suppliers
|
||||
// If bounds filter is active, fetch more and filter client-side
|
||||
// TODO: Add bounds support to exchange backend for proper server-side filtering
|
||||
const bounds = filterBounds.value
|
||||
|
||||
// Validate bounds coordinates
|
||||
const validBounds = bounds &&
|
||||
typeof bounds.west === 'number' && isFinite(bounds.west) &&
|
||||
typeof bounds.south === 'number' && isFinite(bounds.south) &&
|
||||
typeof bounds.east === 'number' && isFinite(bounds.east) &&
|
||||
typeof bounds.north === 'number' && isFinite(bounds.north)
|
||||
|
||||
const fetchLimit = validBounds ? 500 : PAGE_SIZE
|
||||
// Default: fetch all suppliers from GEO (graph-based)
|
||||
const data = await execute(
|
||||
GetSupplierProfilesDocument,
|
||||
{ limit: fetchLimit, offset: validBounds ? 0 : offset },
|
||||
SuppliersListDocument,
|
||||
{ limit: PAGE_SIZE, offset },
|
||||
'public',
|
||||
'exchange'
|
||||
'geo'
|
||||
)
|
||||
let next = data?.getSupplierProfiles || []
|
||||
|
||||
// Client-side bounds filtering (until exchange backend supports it)
|
||||
if (validBounds) {
|
||||
next = next.filter((s: any) => {
|
||||
if (!s.latitude || !s.longitude) return false
|
||||
const lat = Number(s.latitude)
|
||||
const lng = Number(s.longitude)
|
||||
return lat >= bounds.south && lat <= bounds.north
|
||||
&& lng >= bounds.west && lng <= bounds.east
|
||||
})
|
||||
}
|
||||
const next = data?.suppliersList || []
|
||||
|
||||
items.value = replace ? next : items.value.concat(next)
|
||||
total.value = validBounds ? next.length : (data?.getSupplierProfilesCount ?? total.value)
|
||||
// suppliersList doesn't return total count, estimate from fetched items
|
||||
if (replace) {
|
||||
total.value = next.length < PAGE_SIZE ? next.length : next.length + PAGE_SIZE
|
||||
} else if (next.length < PAGE_SIZE) {
|
||||
total.value = items.value.length
|
||||
}
|
||||
isInitialized.value = true
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
|
||||
Reference in New Issue
Block a user