Bug fixes v2

This commit is contained in:
Tim
2023-11-04 13:23:40 +01:00
parent 152743597e
commit 5b7f82a983
2 changed files with 31 additions and 5 deletions

View File

@ -81,11 +81,20 @@ company_relation_type_filter = get_all_company_relations()["relation_type"].uniq
def update_table(
metric_dropdown_value: str, metrics: pd.DataFrame
) -> tuple[dict, list]:
"""_summary_.
Args:
metric_dropdown_value (str): _description_
metrics (pd.DataFrame): _description_
Returns:
tuple[dict, list]: _description_
"""
table_df = metrics.sort_values(metric_dropdown_value, ascending=False).head(10)
table_df = table_df[["designation", "category", metric_dropdown_value]]
table_df.to_dict("records")
columns = [{"name": i, "id": i} for i in table_df.columns]
return table_df.to_dict("records"), columns # type: ignore
return table_df.to_dict("records"), columns # type: ignore
top_companies_dict, top_companies_columns = update_table("closeness", metrics)
@ -314,6 +323,15 @@ def update_graph_data(
person_relation_type: str = "HAFTENDER_GESELLSCHAFTER",
company_relation_type: str = "GESCHAEFTSFUEHRER",
) -> tuple[nx.Graph, pd.DataFrame, dict, list]:
"""_summary_.
Args:
person_relation_type (str, optional): _description_. Defaults to "HAFTENDER_GESELLSCHAFTER".
company_relation_type (str, optional): _description_. Defaults to "GESCHAEFTSFUEHRER".
Returns:
tuple[nx.Graph, pd.DataFrame, dict, list]: _description_
"""
# Get Data
person_df = get_all_person_relations()
company_df = get_all_company_relations()
@ -394,7 +412,7 @@ def update_figure(
selected_metric,
layout,
switch_edge_annotaion_value,
slider_value,# type: ignore
slider_value, # type: ignore
),
)
else:
@ -409,7 +427,7 @@ def update_figure(
selected_metric,
layout,
switch_edge_annotaion_value,
slider_value, # type: ignore
slider_value, # type: ignore
),
)
@ -421,6 +439,14 @@ def update_figure(
],
)
def update_Dropdown(datasource_value: str) -> str:
"""_summary_.
Args:
datasource_value (str): _description_
Returns:
str: _description_
"""
style = ""
match datasource_value:
case "Company Data only":

View File

@ -189,7 +189,7 @@ def filter_relation_with_more_than_one_connection(
if count > 1:
# tmp_df = pd.concat([tmp_df, pd.DataFrame(row)])+
tmp_df.loc[len(tmp_df)] = row # type: ignore
tmp_df.loc[len(tmp_df)] = row # type: ignore
count = 0
else:
count = 0
@ -269,7 +269,7 @@ def create_edge_and_node_list(
def find_company_relations(
selected_company_id: int,
) -> tuple[pd.DataFrame, pd.DataFrame]:
) -> tuple[pd.DataFrame, pd.DataFrame]:
relations_company_query = (
session.query(
to_company.id.label("id_company_to"),