Use graph-based offers and remove radius filters
Some checks failed
Build Docker Image / build (push) Has been cancelled
Some checks failed
Build Docker Image / build (push) Has been cancelled
This commit is contained in:
@@ -61,15 +61,13 @@ export function useCatalogHubs() {
|
||||
const fetchPage = async (offset: number, replace = false) => {
|
||||
if (replace) isLoading.value = true
|
||||
try {
|
||||
// If filtering by product, use nearestHubs with global search
|
||||
// (center point 0,0 with very large radius to cover entire globe)
|
||||
// If filtering by product, use nearestHubs (graph-based)
|
||||
if (filterProductUuid.value) {
|
||||
const data = await execute(
|
||||
NearestHubsDocument,
|
||||
{
|
||||
lat: 0,
|
||||
lon: 0,
|
||||
radius: 20000, // 20000 km radius covers entire Earth
|
||||
productUuid: filterProductUuid.value,
|
||||
useGraph: true,
|
||||
limit: 500 // Increased limit for global search
|
||||
|
||||
@@ -15,7 +15,8 @@ import type {
|
||||
} from '~/composables/graphql/public/exchange-generated'
|
||||
import {
|
||||
GetOfferDocument,
|
||||
GetSupplierProfileDocument
|
||||
GetSupplierProfileDocument,
|
||||
GetSupplierOffersDocument
|
||||
} from '~/composables/graphql/public/exchange-generated'
|
||||
|
||||
// Types from codegen
|
||||
@@ -125,7 +126,8 @@ export function useCatalogInfo() {
|
||||
{
|
||||
lat: coords.lat,
|
||||
lon: coords.lon,
|
||||
radius: 500
|
||||
hubUuid: uuid,
|
||||
limit: 500
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
@@ -224,21 +226,16 @@ export function useCatalogInfo() {
|
||||
isLoadingProducts.value = true
|
||||
isLoadingHubs.value = true
|
||||
|
||||
// Load products (offers grouped by product)
|
||||
// Load products from supplier offers (no geo radius)
|
||||
execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: entity.value.latitude,
|
||||
lon: entity.value.longitude,
|
||||
radius: 500
|
||||
},
|
||||
GetSupplierOffersDocument,
|
||||
{ teamUuid: uuid },
|
||||
'public',
|
||||
'geo'
|
||||
'exchange'
|
||||
).then(offersData => {
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, InfoProductItem>()
|
||||
offersData?.nearestOffers?.forEach(offer => {
|
||||
if (!offer || !offer.productUuid || !offer.productName) return
|
||||
offersData?.getOffers?.forEach(offer => {
|
||||
if (!offer?.productUuid || !offer.productName) return
|
||||
const existing = productsMap.get(offer.productUuid)
|
||||
if (existing) {
|
||||
existing.offersCount = (existing.offersCount || 0) + 1
|
||||
@@ -261,7 +258,6 @@ export function useCatalogInfo() {
|
||||
{
|
||||
lat: entity.value.latitude,
|
||||
lon: entity.value.longitude,
|
||||
radius: 1000,
|
||||
sourceUuid: entity.value.uuid,
|
||||
limit: 12
|
||||
},
|
||||
@@ -312,7 +308,6 @@ export function useCatalogInfo() {
|
||||
{
|
||||
lat: coords.lat,
|
||||
lon: coords.lon,
|
||||
radius: 1000,
|
||||
sourceUuid: entity.value?.uuid ?? null,
|
||||
limit: 12
|
||||
},
|
||||
@@ -372,7 +367,6 @@ export function useCatalogInfo() {
|
||||
lon: hub.longitude,
|
||||
productUuid,
|
||||
hubUuid, // Pass hubUuid to get routes calculated on backend
|
||||
radius: 500,
|
||||
limit: 12
|
||||
},
|
||||
'public',
|
||||
@@ -438,7 +432,6 @@ export function useCatalogInfo() {
|
||||
{
|
||||
lat: supplier.latitude,
|
||||
lon: supplier.longitude,
|
||||
radius: 1000,
|
||||
sourceUuid: supplier.uuid,
|
||||
limit: 1
|
||||
},
|
||||
@@ -462,14 +455,17 @@ export function useCatalogInfo() {
|
||||
lon: supplier.longitude,
|
||||
productUuid,
|
||||
...(hubUuid ? { hubUuid } : {}),
|
||||
radius: 500,
|
||||
limit: 12
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
|
||||
relatedOffers.value = (offersData?.nearestOffers || []).filter((o): o is OfferItem => o !== null)
|
||||
relatedOffers.value = (offersData?.nearestOffers || []).filter((o): o is OfferItem => {
|
||||
if (!o) return false
|
||||
if (!supplier.uuid) return true
|
||||
return o.supplierUuid === supplier.uuid
|
||||
})
|
||||
isLoadingOffers.value = false
|
||||
} finally {
|
||||
isLoadingOffers.value = false
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NearestOffersDocument
|
||||
} from '~/composables/graphql/public/geo-generated'
|
||||
import {
|
||||
GetSupplierProfileDocument
|
||||
GetSupplierOffersDocument
|
||||
} from '~/composables/graphql/public/exchange-generated'
|
||||
|
||||
// Type from codegen
|
||||
@@ -43,46 +43,26 @@ export function useCatalogProducts() {
|
||||
let data
|
||||
|
||||
if (filterSupplierUuid.value) {
|
||||
// Products from specific supplier - get supplier coordinates first
|
||||
const supplierData = await execute(
|
||||
GetSupplierProfileDocument,
|
||||
{ uuid: filterSupplierUuid.value },
|
||||
// Products from specific supplier - get offers directly (no geo radius)
|
||||
const offersData = await execute(
|
||||
GetSupplierOffersDocument,
|
||||
{ teamUuid: filterSupplierUuid.value },
|
||||
'public',
|
||||
'exchange'
|
||||
)
|
||||
const supplier = supplierData?.getSupplierProfile
|
||||
|
||||
if (!supplier?.latitude || !supplier?.longitude) {
|
||||
console.warn('Supplier has no coordinates')
|
||||
items.value = []
|
||||
} else {
|
||||
// Get offers near supplier and group by product
|
||||
const offersData = await execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: supplier.latitude,
|
||||
lon: supplier.longitude,
|
||||
radius: 500
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, AggregatedProduct>()
|
||||
offersData?.nearestOffers?.forEach((offer) => {
|
||||
if (!offer?.productUuid) return
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
})
|
||||
items.value = Array.from(productsMap.values()) as ProductItem[]
|
||||
}
|
||||
const productsMap = new Map<string, AggregatedProduct>()
|
||||
offersData?.getOffers?.forEach((offer) => {
|
||||
if (!offer?.productUuid) return
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
})
|
||||
items.value = Array.from(productsMap.values()) as ProductItem[]
|
||||
} else if (filterHubUuid.value) {
|
||||
// Products near hub - get hub coordinates first
|
||||
const hubData = await execute(
|
||||
@@ -97,13 +77,14 @@ export function useCatalogProducts() {
|
||||
console.warn('Hub has no coordinates')
|
||||
items.value = []
|
||||
} else {
|
||||
// Get offers near hub and group by product
|
||||
// Get offers by graph from hub and group by product
|
||||
const offersData = await execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: hub.latitude,
|
||||
lon: hub.longitude,
|
||||
radius: 500
|
||||
hubUuid: filterHubUuid.value,
|
||||
limit: 500
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
|
||||
@@ -28,15 +28,13 @@ export function useCatalogSuppliers() {
|
||||
const fetchPage = async (offset: number, replace = false) => {
|
||||
if (replace) isLoading.value = true
|
||||
try {
|
||||
// If filtering by product, use nearestSuppliers with global search
|
||||
// (center point 0,0 with very large radius to cover entire globe)
|
||||
// If filtering by product, use nearestSuppliers (product-only list)
|
||||
if (filterProductUuid.value) {
|
||||
const data = await execute(
|
||||
NearestSuppliersDocument,
|
||||
{
|
||||
lat: 0,
|
||||
lon: 0,
|
||||
radius: 20000, // 20000 km radius covers entire Earth
|
||||
productUuid: filterProductUuid.value,
|
||||
limit: 500 // Increased limit for global search
|
||||
},
|
||||
|
||||
@@ -657,7 +657,6 @@ const onSearch = async () => {
|
||||
productUuid: productId.value,
|
||||
hubUuid: hubId.value,
|
||||
quantity: quantity.value ? Number(quantity.value) : null,
|
||||
radius: 500,
|
||||
limit: 10
|
||||
},
|
||||
'public',
|
||||
@@ -682,7 +681,6 @@ const onSearch = async () => {
|
||||
lon: hub.longitude,
|
||||
productUuid: productId.value,
|
||||
hubUuid: hubId.value,
|
||||
radius: 500,
|
||||
limit: 12
|
||||
},
|
||||
'public',
|
||||
|
||||
Reference in New Issue
Block a user