Added a small stability fix. (#374)

The current code has problems with an empty db.
This commit is contained in:
Philipp Horstenkamp 2023-11-12 14:14:15 +01:00 committed by GitHub
parent 24c55c68b7
commit 19a4460d90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -134,8 +134,12 @@ def layout() -> list[html]:
"""Generates the Layout of the Homepage."""
person_relation_types = person_relation_type_filter()
company_relation_types = company_relation_type_filter()
selected_company_relation_types: frozenset[str] = frozenset(
{company_relation_types[1]}
selected_company_relation_types: frozenset[str] = (
frozenset(
{company_relation_types[1]} if company_relation_types else frozenset({})
)
if company_relation_types
else frozenset({})
)
selected_person_relation_types: frozenset[str] = frozenset(
{}

View File

@ -3,7 +3,6 @@ from functools import lru_cache
import networkx as nx
import pandas as pd
from loguru import logger
from sqlalchemy.orm import aliased
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
@ -155,11 +154,9 @@ def filter_relation_type(
relation_dataframe (pd.DataFrame): The filtered DataFrame which now only contains entries with the selected Relation Type.
"""
if selected_relation_type is not None:
filtered = relation_dataframe.loc[
return relation_dataframe.loc[
relation_dataframe["relation_type"].isin(selected_relation_type)
]
logger.info(f"Filtered! {len(filtered.index) / len(relation_dataframe)}")
return filtered
return relation_dataframe