goodmap 0.4.3__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {goodmap-0.4.3 → goodmap-0.5.0}/PKG-INFO +3 -3
- goodmap-0.5.0/goodmap/core.py +46 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/core_api.py +0 -25
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/data_validator.py +1 -1
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/templates/map.html +1 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/pyproject.toml +9 -5
- goodmap-0.4.3/goodmap/core.py +0 -19
- {goodmap-0.4.3 → goodmap-0.5.0}/LICENSE.md +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/README.md +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/__init__.py +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/data_models/location.py +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/db.py +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/formatter.py +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/goodmap.py +0 -0
- {goodmap-0.4.3 → goodmap-0.5.0}/goodmap/templates/admin.html +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: goodmap
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Map engine to serve all the people :)
|
|
5
5
|
Author: Krzysztof Kolodzinski
|
|
6
6
|
Author-email: krzysztof.kolodzinski@problematy.pl
|
|
@@ -22,7 +22,7 @@ Requires-Dist: google-cloud-storage (>=2.7.0,<3.0.0)
|
|
|
22
22
|
Requires-Dist: gql (>=3.4.0,<4.0.0)
|
|
23
23
|
Requires-Dist: gunicorn (>=20.1.0,<21.0.0)
|
|
24
24
|
Requires-Dist: humanize (>=4.6.0,<5.0.0)
|
|
25
|
-
Requires-Dist: platzky (>=0.
|
|
25
|
+
Requires-Dist: platzky (>=0.3.1,<0.4.0)
|
|
26
26
|
Requires-Dist: pydantic (>=2.7.1,<3.0.0)
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
|
+
|
|
3
|
+
# TODO move filtering to db site
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def does_fulfill_requirement(entry, requirements):
|
|
7
|
+
matches = []
|
|
8
|
+
for category, values in requirements:
|
|
9
|
+
if not values:
|
|
10
|
+
continue
|
|
11
|
+
matches.append(all(entry_value in entry[category] for entry_value in values))
|
|
12
|
+
return all(matches)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def sort_by_distance(data: List[Dict[str, Any]], query_params: Dict[str, List[str]]):
|
|
16
|
+
try:
|
|
17
|
+
if "lat" in query_params and "lon" in query_params:
|
|
18
|
+
lat = float(query_params["lat"][0])
|
|
19
|
+
lon = float(query_params["lon"][0])
|
|
20
|
+
data.sort(key=lambda x: (x["position"][0] - lat) ** 2 + (x["position"][1] - lon) ** 2)
|
|
21
|
+
return data
|
|
22
|
+
return data
|
|
23
|
+
except (ValueError, KeyError, IndexError):
|
|
24
|
+
return data
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def limit(data, query_params):
|
|
28
|
+
try:
|
|
29
|
+
if "limit" in query_params:
|
|
30
|
+
limit = int(query_params["limit"][0])
|
|
31
|
+
data = data[:limit]
|
|
32
|
+
return data
|
|
33
|
+
return data
|
|
34
|
+
except (ValueError, KeyError, IndexError):
|
|
35
|
+
return data
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_queried_data(all_data, categories, query_params):
|
|
39
|
+
requirements = []
|
|
40
|
+
for key in categories.keys():
|
|
41
|
+
requirements.append((key, query_params.get(key)))
|
|
42
|
+
|
|
43
|
+
filtered_data = [x for x in all_data if does_fulfill_requirement(x, requirements)]
|
|
44
|
+
final_data = sort_by_distance(filtered_data, query_params)
|
|
45
|
+
final_data = limit(final_data, query_params)
|
|
46
|
+
return final_data
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import importlib.metadata
|
|
2
2
|
import uuid
|
|
3
3
|
|
|
4
|
-
import deprecation
|
|
5
4
|
from flask import Blueprint, jsonify, make_response, request
|
|
6
5
|
from flask_babel import gettext
|
|
7
6
|
from flask_restx import Api, Resource, fields
|
|
8
7
|
from platzky.config import LanguagesMapping
|
|
9
8
|
|
|
10
|
-
from goodmap.core import get_queried_data
|
|
11
9
|
from goodmap.formatter import prepare_pin
|
|
12
10
|
|
|
13
11
|
|
|
@@ -76,29 +74,6 @@ def core_pages(
|
|
|
76
74
|
return make_response(jsonify({"message": f"{error_message} : {e}"}), 400)
|
|
77
75
|
return make_response(jsonify({"message": gettext("Location reported")}), 200)
|
|
78
76
|
|
|
79
|
-
@core_api.route("/data")
|
|
80
|
-
class Data(Resource):
|
|
81
|
-
@deprecation.deprecated(
|
|
82
|
-
deprecated_in="0.4.1",
|
|
83
|
-
removed_in="0.5.0",
|
|
84
|
-
current_version=importlib.metadata.version("goodmap"),
|
|
85
|
-
details="Use /locations or /location/<point_id> instead",
|
|
86
|
-
)
|
|
87
|
-
def get(self):
|
|
88
|
-
"""
|
|
89
|
-
Shows all data filtered by query parameters
|
|
90
|
-
e.g. /api/data?category=category1&category=category2
|
|
91
|
-
"""
|
|
92
|
-
all_data = database.get_data()
|
|
93
|
-
query_params = request.args.to_dict(flat=False)
|
|
94
|
-
data = all_data["data"]
|
|
95
|
-
categories = all_data["categories"]
|
|
96
|
-
visible_data = all_data["visible_data"]
|
|
97
|
-
meta_data = all_data["meta_data"]
|
|
98
|
-
queried_data = get_queried_data(data, categories, query_params)
|
|
99
|
-
formatted_data = [prepare_pin(x, visible_data, meta_data) for x in queried_data]
|
|
100
|
-
return jsonify(formatted_data)
|
|
101
|
-
|
|
102
77
|
@core_api.route("/locations")
|
|
103
78
|
class GetLocations(Resource):
|
|
104
79
|
def get(self):
|
|
@@ -50,7 +50,7 @@ def get_invalid_value_in_category_violations(p, categories):
|
|
|
50
50
|
for category in categories & p.keys():
|
|
51
51
|
category_value_in_point = p[category]
|
|
52
52
|
valid_values_set = categories[category]
|
|
53
|
-
if
|
|
53
|
+
if isinstance(category_value_in_point, list):
|
|
54
54
|
for attribute_value in category_value_in_point:
|
|
55
55
|
if attribute_value not in valid_values_set:
|
|
56
56
|
violations.append(
|
|
@@ -116,6 +116,7 @@ window.PRIMARY_COLOR = "{{ primary_color }}";
|
|
|
116
116
|
window.SHOW_SUGGEST_NEW_POINT_BUTTON = {{ feature_flags.SHOW_SUGGEST_NEW_POINT_BUTTON | default(false) | tojson }};
|
|
117
117
|
window.SHOW_SEARCH_BAR = {{ feature_flags.SHOW_SEARCH_BAR | default(false) | tojson }};
|
|
118
118
|
window.USE_LAZY_LOADING = {{ feature_flags.USE_LAZY_LOADING | default(false) | tojson }};
|
|
119
|
+
window.SHOW_ACCESSIBILITY_TABLE = {{ feature_flags.SHOW_ACCESSIBILITY_TABLE | default(false) | tojson }};
|
|
119
120
|
</script>
|
|
120
121
|
<script src="/static/map.js"></script>
|
|
121
122
|
{% endblock %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "goodmap"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
description = "Map engine to serve all the people :)"
|
|
5
5
|
authors = ["Krzysztof Kolodzinski <krzysztof.kolodzinski@problematy.pl>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -20,7 +20,7 @@ Flask-WTF = "^1.2.1"
|
|
|
20
20
|
gql = "^3.4.0"
|
|
21
21
|
aiohttp = "^3.8.4"
|
|
22
22
|
pydantic = "^2.7.1"
|
|
23
|
-
platzky = "^0.
|
|
23
|
+
platzky = "^0.3.1"
|
|
24
24
|
deprecation = "^2.1.0"
|
|
25
25
|
|
|
26
26
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -30,8 +30,9 @@ coveralls = "^3.3.1"
|
|
|
30
30
|
pyright = "^1.1.291"
|
|
31
31
|
freezegun = "^1.2.2"
|
|
32
32
|
black = "^24.8.0"
|
|
33
|
-
ruff = "^0.
|
|
33
|
+
ruff = "^0.4.4"
|
|
34
34
|
platzky = {path = "vendor/platzky", develop = true}
|
|
35
|
+
platzky-redirections = "^0.1.0"
|
|
35
36
|
|
|
36
37
|
[build-system]
|
|
37
38
|
requires = ["poetry-core>=1.0.0"]
|
|
@@ -55,6 +56,10 @@ reportUntypedClassDecorator = false
|
|
|
55
56
|
reportUnusedClass = false
|
|
56
57
|
reportUntypedBaseClass = false
|
|
57
58
|
|
|
59
|
+
exclude = [
|
|
60
|
+
"**/vendor/**",
|
|
61
|
+
]
|
|
62
|
+
|
|
58
63
|
[tool.black]
|
|
59
64
|
line-length = 100
|
|
60
65
|
target-version = ["py310"]
|
|
@@ -63,14 +68,13 @@ target-version = ["py310"]
|
|
|
63
68
|
line-length = 100
|
|
64
69
|
target-version = "py310"
|
|
65
70
|
show-fixes = true
|
|
66
|
-
select = [
|
|
71
|
+
lint.select = [
|
|
67
72
|
"I", # isort
|
|
68
73
|
"F", # Pyflakes
|
|
69
74
|
"E", # pycodestyle Error
|
|
70
75
|
"W", # pycodestyle Warning
|
|
71
76
|
"RUF", # Ruff-specific rules
|
|
72
77
|
]
|
|
73
|
-
ignore = []
|
|
74
78
|
|
|
75
79
|
[tool.pytest.ini_options]
|
|
76
80
|
addopts = "--ignore=vendor"
|
goodmap-0.4.3/goodmap/core.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# TODO move filtering to db site
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def does_fulfill_requirement(entry, requirements):
|
|
5
|
-
matches = []
|
|
6
|
-
for category, values in requirements:
|
|
7
|
-
if not values:
|
|
8
|
-
continue
|
|
9
|
-
matches.append(all(entry_value in entry[category] for entry_value in values))
|
|
10
|
-
return all(matches)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def get_queried_data(all_data, categories, query_params):
|
|
14
|
-
requirements = []
|
|
15
|
-
for key in categories.keys():
|
|
16
|
-
requirements.append((key, query_params.get(key)))
|
|
17
|
-
|
|
18
|
-
filtered_data = [x for x in all_data if does_fulfill_requirement(x, requirements)]
|
|
19
|
-
return filtered_data
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|