Skip to content

Commit

Permalink
Merge pull request #202 from InTaVia/ms/196-filter-for-`entityType-==…
Browse files Browse the repository at this point in the history
…-group`-results-in-internal-server-error

Ms/196 filter for `entity type == group` results in internal server error
  • Loading branch information
sennierer authored Aug 31, 2023
2 parents a5235e7 + 74a67e3 commit 71980ec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions intavia_backend/intavia_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Wrapper around the FastApiCache-2 library"""
import os
from fastapi_cache.decorator import cache


def nocache(*args, **kwargs):
def decorator(func):
return func
return decorator

# I have an .env file, and my get_settings() reads the .env file
if os.environ.get("APIS_REDIS_CACHING", "True") == "True":
cache = cache
else:
cache = nocache
2 changes: 1 addition & 1 deletion intavia_backend/main_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from fastapi_cache import FastAPICache
from fastapi_cache.backends.redis import RedisBackend
from fastapi_cache.decorator import cache
from .intavia_cache import cache
from .utils import get_query_from_triplestore


Expand Down
2 changes: 1 addition & 1 deletion intavia_backend/main_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import math
import dateutil
from fastapi import APIRouter, Depends, HTTPException
from fastapi_cache.decorator import cache
from .intavia_cache import cache
import requests

from fastapi_versioning import version, versioned_api_route
Expand Down
5 changes: 4 additions & 1 deletion intavia_backend/models_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def pp_id_provider(field, item, data):
it = "/".join(it["id"].split("/")[:-1])
else:
it = it["id"]
test_uri_valid = re.match(r"^(https?://.+[a-z])([0-9]+$)", it)
if test_uri_valid: #TODO: this is a hack, should be fixed in the data (none-valid URIs should be removed)
it = f"{test_uri_valid.group(1)}/{test_uri_valid.group(2)}"
data["url"] = it
for k, v in linked_id_providers.items():
if v["baseUrl"] in it:
Expand Down Expand Up @@ -200,7 +203,7 @@ class Config:
RDF_utils_move_errors_to_top = True


class LinkedId(BaseModel):
class LinkedId(IntaViaBackendBaseModel):
label: str
url: HttpUrl

Expand Down

0 comments on commit 71980ec

Please sign in to comment.