Skip to content

Commit b3861d5

Browse files
Merge pull request #4 from reloc8/minor/remove-bounding-box
Remove bounding box from query response
2 parents 4ab6af2 + 4f43fe4 commit b3861d5

6 files changed

Lines changed: 4 additions & 70 deletions

File tree

fetch_properties/core/mapper/__init__.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import libgeohash
21
from typing import Any, AnyStr, Dict, List
32

43
from ..schema import Property, PropertyLocation, PropertiesPage, LocalStatistics, GlobalStatistics, Statistics, \
5-
PriceStatistics, LocationBoundingBox, Point
4+
PriceStatistics
65

76

87
class PropertyMapper:
@@ -54,12 +53,11 @@ def map(local_statistics: List[LocalStatistics], global_statistics: GlobalStatis
5453
class LocalStatisticsMapper:
5554

5655
@staticmethod
57-
def map(price_statistics: PriceStatistics, geohash: AnyStr, bounding_box: LocationBoundingBox) -> LocalStatistics:
56+
def map(price_statistics: PriceStatistics, geohash: AnyStr) -> LocalStatistics:
5857

5958
mapped = LocalStatistics()
6059
mapped.price = price_statistics
6160
mapped.geohash = geohash
62-
mapped.bounding_box = bounding_box
6361

6462
return mapped
6563

@@ -86,23 +84,3 @@ def map(min_price, max_price, avg_price) -> PriceStatistics:
8684
mapped.avg = avg_price
8785

8886
return mapped
89-
90-
91-
class LocationBoundingBoxMapper:
92-
93-
@staticmethod
94-
def map(geohash: AnyStr) -> LocationBoundingBox:
95-
96-
reversed_geohash = libgeohash.bbox(geohash)
97-
98-
mapped = LocationBoundingBox()
99-
top_right = Point()
100-
top_right.latitude = reversed_geohash.get('n')
101-
top_right.longitude = reversed_geohash.get('e')
102-
mapped.top_right = top_right
103-
bottom_left = Point()
104-
bottom_left.latitude = reversed_geohash.get('s')
105-
bottom_left.longitude = reversed_geohash.get('w')
106-
mapped.bottom_left = bottom_left
107-
108-
return mapped

fetch_properties/core/schema/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class LocationBoundingBox(graphene.ObjectType):
4343
class LocalStatistics(graphene.ObjectType):
4444

4545
geohash = graphene.String()
46-
bounding_box = graphene.Field(LocationBoundingBox)
4746
price = graphene.Field(PriceStatistics)
4847

4948

fetch_properties/core/schema/resolver.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from . import SearchBoundingBox, PropertyFilter, PropertiesPage, Statistics
99
from ..mapper import PropertyMapper, PropertiesPageMapper, LocalStatisticsMapper, PriceStatisticsMapper, \
10-
LocationBoundingBoxMapper, GlobalStatisticsMapper, StatisticsMapper
10+
GlobalStatisticsMapper, StatisticsMapper
1111
from ..mongodb import MongoDBConnection, MONGODB_CONNECTION
1212

1313

@@ -197,11 +197,9 @@ def find_statistics_by_filter(self, filter: PropertyFilter) -> Statistics:
197197
avg_price=result.get('price').get('avg')
198198
)
199199
geohash = result.get('geohash')
200-
bounding_box = LocationBoundingBoxMapper.map(geohash=geohash)
201200
local_statistics.append(LocalStatisticsMapper.map(
202201
price_statistics=price_statistics,
203-
geohash=geohash,
204-
bounding_box=bounding_box
202+
geohash=geohash
205203
))
206204

207205
global_result = list(global_results)[0]

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def private_dependency(personal_access_token: AnyStr,
3636
'dnspython',
3737
'pymongo',
3838
'graphene',
39-
'libgeohash',
4039
private_dependency(personal_access_token=GITHUB_PERSONAL_ACCESS_TOKEN,
4140
repo_user='reloc8', repo_name='lib-lambda-handler',
4241
package_name='lambda_handler', package_version='1.0.0')

tests/resources/query-3.graphql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@
1414
) {
1515
localStatistics {
1616
geohash
17-
boundingBox {
18-
bottomLeft {
19-
latitude
20-
longitude
21-
}
22-
topRight {
23-
latitude
24-
longitude
25-
}
26-
}
2717
price {
2818
min
2919
max

tests/resources/response-body-3.json

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44
"localStatistics": [
55
{
66
"geohash": "u0j0r1m",
7-
"boundingBox": {
8-
"bottomLeft": {
9-
"latitude": 45.050811767578125,
10-
"longitude": 7.345733642578125
11-
},
12-
"topRight": {
13-
"latitude": 45.05218505859375,
14-
"longitude": 7.34710693359375
15-
}
16-
},
177
"price": {
188
"min": 350000,
199
"max": 350000,
@@ -22,16 +12,6 @@
2212
},
2313
{
2414
"geohash": "u0j3xvj",
25-
"boundingBox": {
26-
"bottomLeft": {
27-
"latitude": 45.2911376953125,
28-
"longitude": 7.730255126953125
29-
},
30-
"topRight": {
31-
"latitude": 45.292510986328125,
32-
"longitude": 7.73162841796875
33-
}
34-
},
3515
"price": {
3616
"min": 279000,
3717
"max": 279000,
@@ -40,16 +20,6 @@
4020
},
4121
{
4222
"geohash": "u0j2w6u",
43-
"boundingBox": {
44-
"bottomLeft": {
45-
"latitude": 45.102996826171875,
46-
"longitude": 7.6629638671875
47-
},
48-
"topRight": {
49-
"latitude": 45.1043701171875,
50-
"longitude": 7.664337158203125
51-
}
52-
},
5323
"price": {
5424
"min": 135000,
5525
"max": 135000,

0 commit comments

Comments
 (0)