Skip to content

Commit

Permalink
atualiza endpoint que busca por ocorrencias cadastradas
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinicius Gama committed Jun 30, 2017
1 parent 6448405 commit 01e248e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 70 deletions.
4 changes: 2 additions & 2 deletions www/conf/stubserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ app.get('/', function (req, res) {
res.send("hello world");
});

app.get('/risks-around', function(req, res) {
app.get('/reports/:geolocation', function(req, res) {
fs.readFile('www/stubs/places.json', function(error, data) {
if(!error) {
res.send(JSON.parse(data));
Expand All @@ -22,4 +22,4 @@ app.get('/risks-around', function(req, res) {
});
});

app.listen(3000, function () {});
app.listen(3001, function () {});
7 changes: 1 addition & 6 deletions www/js/factory/place.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
return placeObject;

function fetchPlaces(lat, long) {
return $http.get('http://0.0.0.0:3000/risks-around', {
params: {
latitude: lat,
longitude: long
}
});
return $http.get('http://0.0.0.0:3001/reports/' + lat + ',' + long);
}

function addPlace(place) {
Expand Down
85 changes: 24 additions & 61 deletions www/stubs/places.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,28 @@
[{
"address": "Av. Ipiranga",
"location": {
"latitude": 10,
"longitude": 20
},
"occurrences": [{
"risk": "Roubo",
"numberOfOccurrences": 2,
"reports": [
{
"date": "10/10/2016",
"period": "Manhã"
},
{
"date": "12/10/2016",
"period": "Manhã"
}]},
[
{
"risk": "Local Mal Iluminado",
"numberOfOccurrences": 2,
"reports": [
{
"date": "10/10/2016",
"period": "Manhã"
},
{
"date": "12/10/2016",
"period": "Manhã"
}]
}]
},
{
"address": "Bento Gonçalves",
"location": {
"latitude": 30,
"longitude": 50
},
"occurrences": [{
"risk": "Roubo",
"numberOfOccurrences": 4,
"reports": [
{
"date": "22/06/2016",
"period": "Manhã"
"_id": "594fd5dd6aa2cec76f591cd9",
"updatedAt": "2017-06-25T15:25:17.331Z",
"createdAt": "2017-06-25T15:25:17.331Z",
"address": "R. Vicente da Fontoura, 2265 - Rio Branco, Porto Alegre - RS, 90640-002, Brazil",
"geolocation": [
-30.0422047,
-51.1963351
],
"category": "Local deserto",
"__v": 0,
"date": "2017-10-10T23:10:00.000Z"
},
{
"date": "23/06/2016",
"period": "Noite"
}]},
{
"risk": "Local Mal Iluminado",
"numberOfOccurrences": 8,
"reports": [
{
"date": "16/07/2016",
"period": "Manhã"
},
{
"date": "12/10/2016",
"period": "Tarde"
}]
}]
}
"_id": "588fe45015c4689ee700e25d",
"updatedAt": "2017-01-31T01:11:44.324Z",
"createdAt": "2017-01-31T01:11:44.324Z",
"address": "R. Vicente da Fontoura - Rio Branco, Porto Alegre - RS, 90640-001, Brazil",
"geolocation": [
-30.04785579999999,
-51.200179400000025
],
"category": "Latrocínio",
"__v": 0,
"date": "2010-10-10T13:10:00.000Z"
}
]
2 changes: 1 addition & 1 deletion www/test/unit/factory/place.factory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Place Factory', function() {

it('should return places', function() {
var url, result;
url = 'http://0.0.0.0:3000/risks-around?latitude=-30.057977&longitude=-30.0123';
url = 'http://0.0.0.0:3001/reports/-30.057977,-30.0123';

httpBackend.whenGET(url).respond(httpResponse);

Expand Down

0 comments on commit 01e248e

Please sign in to comment.