Skip to content

Commit

Permalink
minor formating fixes dictated by our formatting suite
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Oct 22, 2022
1 parent 172162a commit c20c4ec
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 25 deletions.
3 changes: 2 additions & 1 deletion data/processors/export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pathlib import Path
from typing import Union, Any
from typing import Any, Union

OUTPUT_DIR = Path(__file__).parent.parent / "output"

Expand Down Expand Up @@ -51,6 +51,7 @@ def export_for_search(data, path):
# also this puts more emphasis on the order (because "." counts as more distance)
"ms_id": _id.replace(".", "-"),
"id": _id, # not searchable

"name": _data["name"],
"arch_name": _data.get("tumonline_data", {}).get("arch_name", None),
"type": _data["type"],
Expand Down
3 changes: 2 additions & 1 deletion data/processors/structure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging

from utils import TranslatableStr as _


Expand Down Expand Up @@ -42,7 +43,7 @@ def add_stats(data):
if not child.get("usage", {}).get("din_277", "").startswith("VF"):
n_rooms_reg += 1
if child["type"] == "joined_building" or (
child["type"] == "building" and data[child["parents"][-1]]["type"] != "joined_building"
child["type"] == "building" and data[child["parents"][-1]]["type"] != "joined_building"
):
n_buildings += 1

Expand Down
8 changes: 4 additions & 4 deletions data/translations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Adresse: Address
Anzahl Gebäude: Number of buildings
Sitzplätze: Seats
Anzahl Räume: Number of rooms
'{n_rooms} ({n_rooms_reg} ohne Flure etc.)': '{n_rooms} ({n_rooms_reg} without corridors etc.)'
"{n_rooms} ({n_rooms_reg} ohne Flure etc.)": "{n_rooms} ({n_rooms_reg} without corridors etc.)"
Keine Räume bekannt: No rooms known
'{n_rooms} Räume': '{n_rooms} rooms'
'{n_buildings} Gebäude, {n_rooms} Räume': '{n_buildings} buildings, {n_rooms} rooms'
'{n_buildings} Gebäude, {n_rooms} Räume (Außenstelle)': '{n_buildings} buildings, {n_rooms} rooms (branch office)'
"{n_rooms} Räume": "{n_rooms} rooms"
"{n_buildings} Gebäude, {n_rooms} Räume": "{n_buildings} buildings, {n_rooms} rooms"
"{n_buildings} Gebäude, {n_rooms} Räume (Außenstelle)": "{n_buildings} buildings, {n_rooms} rooms (branch office)"
Architekten-Name: Architect's name
# type_common_name
Gebäudeteil: Part of the building
Expand Down
2 changes: 1 addition & 1 deletion data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TranslatableStr(dict):
Since it is a subclass of dict, this class does not need any additional infrastructure
to turn a message into a translated string.
Translatable strings will be exported as {"de": "<de string>", "en": "<en string>"}.
"""

Expand Down
4 changes: 3 additions & 1 deletion deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ Genreral information:
### Environment Based Deployment

We have two different kinds of environments:

- staging
- production

The only difference between the two is, that production has some extra secrets.
Namely:

- we don't publish our `GITHUB_TOKEN` to git. (used to pass feedback from the webclient to github)
- we don't publish the `MEILI_MASTER_KEY` to git. (used as aditional layer of network hardening between the webclient and the server)

Deployment happens on push to main, or on push to a PR.
For PRs we only execute this deployment request, if the autor is a member of the `@TUM-Dev/navigatum`-group or a member authorises this PR to run actions.
The reasoning is, that we don't want strangers to be able to fork our project, change the deployment to something malicious and make us deploy it.
The reasoning is, that we don't want strangers to be able to fork our project, change the deployment to something malicious and make us deploy it.
11 changes: 5 additions & 6 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ paths:
parameters:
- name: lang
in: query
description: The language you want your details to be in. If either this or the query parameter is set to en, this will be delivered.
description: 'The language you want your details to be in. If either this or the query parameter is set to en, this will be delivered.'
required: false
schema:
type: string
Expand All @@ -294,7 +294,7 @@ paths:
- en
- name: lang
in: cookie
description: The language you want your details to be in. If either this or the query parameter is set to en, this will be delivered.
description: 'The language you want your details to be in. If either this or the query parameter is set to en, this will be delivered.'
required: false
schema:
type: string
Expand Down Expand Up @@ -578,7 +578,7 @@ paths:
parameters:
- name: lang
in: query
description: The language you want your preview to be in. If either this or the query parameter is set to en, this will be delivered.
description: 'The language you want your preview to be in. If either this or the query parameter is set to en, this will be delivered.'
required: false
schema:
type: string
Expand All @@ -588,7 +588,7 @@ paths:
- en
- name: lang
in: cookie
description: The language you want your preview to be in. If either this or the query parameter is set to en, this will be delivered.
description: 'The language you want your preview to be in. If either this or the query parameter is set to en, this will be delivered.'
required: false
schema:
type: string
Expand Down Expand Up @@ -638,8 +638,7 @@ paths:
description: More data about the requested building/room
content:
image/png:
shema:
type:binary
shema: 'type:binary'
'404':
description: Invalid input
content:
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ structopt = "0.3.26"
env_logger = "0.9.0"
image = "0.24.3"
rusttype= "0.9.2"
imageproc= "0.23.0"
imageproc= "0.23.0"
2 changes: 1 addition & 1 deletion server/Dockerfile.mielesearch
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ COPY --from=build-stage /meili_data/data.ms ./data.ms

EXPOSE 7700
ENTRYPOINT meilisearch
HEALTHCHECK --interval=5s --timeout=5s --start-period=60s --retries=5 CMD curl -f http://localhost:7700/health || exit 1
HEALTHCHECK --interval=5s --timeout=5s --start-period=60s --retries=5 CMD curl -f http://localhost:7700/health || exit 1
28 changes: 20 additions & 8 deletions server/load_api_data_to_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
def add_to_database(de_data, en_data):
"""add data consisting of 2x(key, data_json, data) to the sqlite database"""
con: sqlite3.Connection = sqlite3.connect("data/api_data.db")
con.execute("""
con.execute(
"""
CREATE TABLE IF NOT EXISTS de (
key VARCHAR(30) UNIQUE PRIMARY KEY NOT NULL,
name VARCHAR(30),
Expand All @@ -15,8 +16,10 @@ def add_to_database(de_data, en_data):
lat FLOAT,
lon FLOAT,
data BLOB NOT NULL
);""")
con.execute("""
);""",
)
con.execute(
"""
CREATE TABLE IF NOT EXISTS en (
key VARCHAR(30) UNIQUE PRIMARY KEY NOT NULL,
name VARCHAR(30),
Expand All @@ -25,14 +28,22 @@ def add_to_database(de_data, en_data):
lat FLOAT,
lon FLOAT,
data BLOB NOT NULL
);""")
);""",
)
# we are using this file in docker, so we don't want to use an acid compliant database ;)
con.execute("""PRAGMA journal_mode = OFF;""")
con.execute("""PRAGMA synchronous = OFF;""")

def map_data(key, data_json, data):
return (key, data_json, data["name"], data["type"], data["type_common_name"],
data.get("coords", {}).get("lat", 48.14903), data.get("coords", {}).get("lon", 11.56735))
return (
key,
data_json,
data["name"],
data["type"],
data["type_common_name"],
data.get("coords", {}).get("lat", 48.14903),
data.get("coords", {}).get("lon", 11.56735),
)

de_data = [map_data(key, data_json, data) for (key, data_json, data) in de_data]
en_data = [map_data(key, data_json, data) for (key, data_json, data) in en_data]
Expand Down Expand Up @@ -65,8 +76,9 @@ def get_localised_data() -> tuple[translated_list, translated_list]:
"""get all data from the json dump and convert it to a list of tuples"""
with open("data/api_data.json", encoding="utf-8") as file:
data = json.load(file)
split_data: list[tuple[str, Any, Any]] = [(key, localise(value, "de"), localise(value, "en")) for key, value in
data.items()]
split_data: list[tuple[str, Any, Any]] = [
(key, localise(value, "de"), localise(value, "en")) for key, value in data.items()
]

de_data = []
en_data = []
Expand Down
2 changes: 1 addition & 1 deletion server/src/maps/font/SIL Open Font License.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ TERMINATION
This license becomes null and void if any of the above conditions are not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

0 comments on commit c20c4ec

Please sign in to comment.