Fix supplier query - aggregate through offers
All checks were successful
Build Docker Image / build (push) Successful in 1m21s
All checks were successful
Build Docker Image / build (push) Successful in 1m21s
Only show suppliers that have active offers.
This commit is contained in:
@@ -43,11 +43,26 @@ def _fetch_nodes(db, transport_type=None, node_type=None):
|
||||
RETURN node
|
||||
"""
|
||||
elif node_type == 'supplier':
|
||||
# Get suppliers that have offers (aggregate through offers)
|
||||
aql = """
|
||||
FOR node IN nodes
|
||||
FILTER node.node_type == 'supplier'
|
||||
FILTER node.latitude != null AND node.longitude != null
|
||||
RETURN node
|
||||
FOR offer IN nodes
|
||||
FILTER offer.node_type == 'offer'
|
||||
FILTER offer.supplier_uuid != null
|
||||
LET supplier = DOCUMENT(CONCAT('nodes/', offer.supplier_uuid))
|
||||
FILTER supplier != null
|
||||
FILTER supplier.latitude != null AND supplier.longitude != null
|
||||
COLLECT sup_uuid = offer.supplier_uuid INTO offers
|
||||
LET sup = DOCUMENT(CONCAT('nodes/', sup_uuid))
|
||||
RETURN {
|
||||
_key: sup_uuid,
|
||||
name: sup.name,
|
||||
latitude: sup.latitude,
|
||||
longitude: sup.longitude,
|
||||
country: sup.country,
|
||||
country_code: sup.country_code,
|
||||
node_type: 'supplier',
|
||||
offers_count: LENGTH(offers)
|
||||
}
|
||||
"""
|
||||
else: # logistics (default)
|
||||
aql = """
|
||||
|
||||
Reference in New Issue
Block a user