Require complete landing network stories
Build and deploy Docker image / build (push) Successful in 32s

This commit is contained in:
Ruslan Bakiev
2026-08-22 19:37:13 +07:00
parent b2a2c840e4
commit a7bb8a9444
+19 -3
View File
@@ -354,6 +354,14 @@ async function resolveLandingNetworkStory(focusKind: LandingNetworkKind, itemLim
LIMIT 1 LIMIT 1
RETURN 1 RETURN 1
) > 0 ) > 0
FILTER LENGTH(
FOR hub IN nodes
FILTER hub.node_type == 'logistics' OR hub.node_type == null
FILTER hub.product_uuid == null
FILTER hub.latitude != null AND hub.longitude != null
LIMIT 1
RETURN 1
) > 0
SORT RAND() SORT RAND()
LIMIT 1 LIMIT 1
RETURN supplier RETURN supplier
@@ -384,7 +392,10 @@ async function resolveLandingNetworkStory(focusKind: LandingNetworkKind, itemLim
LIMIT @limit LIMIT @limit
RETURN MERGE(hub, {distance_km: dist}) RETURN MERGE(hub, {distance_km: dist})
`, { lat: focus.latitude, lon: focus.longitude, limit }) `, { lat: focus.latitude, lon: focus.longitude, limit })
const hubs = await hubsCursor.all() const hubs = await hubsCursor.all() as ArangoDoc[]
if (offers.length === 0 || hubs.length === 0) {
throw new Error('No complete supplier story with offers and nearby hubs is available')
}
return { return {
focus: mapLandingNetworkPoint(focus, 'SUPPLIER'), focus: mapLandingNetworkPoint(focus, 'SUPPLIER'),
offers: offers.map(mapLandingNetworkOffer), offers: offers.map(mapLandingNetworkOffer),
@@ -434,12 +445,17 @@ async function resolveLandingNetworkStory(focusKind: LandingNetworkKind, itemLim
`, { lat: focus.latitude, lon: focus.longitude, offer_limit: limit * 4 }) `, { lat: focus.latitude, lon: focus.longitude, offer_limit: limit * 4 })
const offers = await offersCursor.all() as ArangoDoc[] const offers = await offersCursor.all() as ArangoDoc[]
const visibleOffers = offers.slice(0, limit) const visibleOffers = offers.slice(0, limit)
const products = landingProductsFromOffers(visibleOffers, limit)
const suppliers = landingSuppliersFromOffers(visibleOffers, limit)
if (visibleOffers.length === 0 || products.length === 0 || suppliers.length === 0) {
throw new Error('No complete hub story with nearby products and suppliers is available')
}
return { return {
focus: mapLandingNetworkPoint(focus, 'HUB'), focus: mapLandingNetworkPoint(focus, 'HUB'),
offers: visibleOffers.map(mapLandingNetworkOffer), offers: visibleOffers.map(mapLandingNetworkOffer),
hubs: [], hubs: [],
products: landingProductsFromOffers(visibleOffers, limit), products,
suppliers: landingSuppliersFromOffers(visibleOffers, limit), suppliers,
} }
} }