#!/bin/bash ################################################################################ # Author: Fred (support@qo-op.com) # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ # TODO: SMS Alerte quand une annonce GCHANGE est proche du GeoPoint du téléphone/membre # # EXTRAIT LES DERNIERES ANNNONCES # TODO Requête ES sur la distance directement !!!! @kimamila or http://www.elasticsearchtutorial.com/spatial-search-tutorial.html help? CESIUM="https://g1.data.le-sou.org" echo "Entrez PubKey"; read DESTRIB; curl -sk ${CESIUM}/user/profile/${DESTRIB} -o /tmp/profile.json LON=$(cat /tmp/profile.json | jq '._source.geoPoint.lon') LAT=$(cat /tmp/profile.json | jq '._source.geoPoint.lat') if [[ "$LON" != "null" ]]; then curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=title' -d ' { "size": 100, "query": { "bool": { "filter": [{ "geo_distance": { "distance": "100km", "geoPoint": { "lat": '$LAT', "lon": '$LON' } } }] } } }' | jq else echo "Aucune coordonnées geoPoint pour $DESTRIB" fi TOTAL=$(curl -s https://data.gchange.fr/market/record/_search | jq .hits.total) echo "TOTAL ANNONCES GCHANGE: $TOTAL" chunk=0 while [[ $chunk -lt $TOTAL ]]; do for res in $(curl -s https://data.gchange.fr/market/record/_search?from=$chunk | jq .hits.hits[]._id | sed s/\"//g ) do; echo $res; # curl -s --create-dirs -o ./gchange/$ID.json -s https://data.gchange.fr/market/record/$ID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,thumbnail._content_type,picturesCount,type,stock,fees,feesCurrency,geoPoint done chunk=$((chunk+10)) done