#!/bin/bash ################################################################################ # Author: Fred (support@qo-op.com) # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ # TODO: SMS/SSB Alert when any gchange.fr ads is close to geopoint # # Extract last ads # TODO Search ES with distance !!!! contact @kimamila or http://www.elasticsearchtutorial.com/spatial-search-tutorial.html ipfsnodeid=$(ipfs id -f='\n') [[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) CESIUM="https://g1.data.le-sou.org" curl -sk ${CESIUM}/user/profile/${g1pub} -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 $g1pub" && exit 1 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