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