mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-20 11:52:54 +02:00
Removed dead docstrings
This commit is contained in:
parent
609599f9f3
commit
1785114ec1
@ -11,14 +11,7 @@ test_company = 13 # 2213 # 13
|
||||
|
||||
|
||||
def find_company_relations(company_id: int) -> pd.DataFrame:
|
||||
"""_summary_.
|
||||
|
||||
Args:
|
||||
company_id (int): _description_
|
||||
|
||||
Returns:
|
||||
pd.DataFrame: _description_
|
||||
"""
|
||||
"""_summary_."""
|
||||
session = connector.get_session(JsonFileConfigProvider("./secrets.json"))
|
||||
query_companies = session.query(entities.Company)
|
||||
query_relations = session.query(entities.CompanyRelation)
|
||||
@ -54,14 +47,7 @@ def find_company_relations(company_id: int) -> pd.DataFrame:
|
||||
|
||||
# Plotly figure
|
||||
def network_graph(company_id: int) -> go.Figure:
|
||||
"""_summary_.
|
||||
|
||||
Args:
|
||||
company_id (int): _description_
|
||||
|
||||
Returns:
|
||||
go.Figure: _description_
|
||||
"""
|
||||
"""_summary_."""
|
||||
edges = []
|
||||
for _, row in find_company_relations(company_id).iterrows():
|
||||
edges.append([row["company_name"], row["connected_company_name"]])
|
||||
@ -136,14 +122,7 @@ def network_graph(company_id: int) -> go.Figure:
|
||||
|
||||
|
||||
def networkx_component(company_id: int) -> html.Div:
|
||||
"""Retruns the Layout with a Graph.
|
||||
|
||||
Args:
|
||||
company_id (int): _description_
|
||||
|
||||
Returns:
|
||||
any: _description_
|
||||
"""
|
||||
"""Returns the Layout with a Graph."""
|
||||
return html.Div(
|
||||
[
|
||||
dcc.Graph(id="my-graph", figure=network_graph(company_id)),
|
||||
|
@ -11,11 +11,7 @@ test_company = 13 # 2213 # 13
|
||||
|
||||
|
||||
def find_all_company_relations() -> pd.DataFrame:
|
||||
"""Searches for all companies and their relation in the DB.
|
||||
|
||||
Returns:
|
||||
pd.DataFrame: _description_
|
||||
"""
|
||||
"""Searches for all companies and their relation in the DB."""
|
||||
session = connector.get_session(JsonFileConfigProvider("./secrets.json"))
|
||||
query_companies = session.query(entities.Company) # .all()
|
||||
query_relations = session.query(entities.CompanyRelation) # .all()
|
||||
@ -57,11 +53,7 @@ def find_all_company_relations() -> pd.DataFrame:
|
||||
|
||||
# Plotly figure
|
||||
def create_network_graph() -> go.Figure:
|
||||
"""Create a NetworkX Graph.
|
||||
|
||||
Returns:
|
||||
go.Figure: _description_
|
||||
"""
|
||||
"""Create a NetworkX Graph."""
|
||||
edges = []
|
||||
for _, row in find_all_company_relations().iterrows():
|
||||
edges.append([row["company_name"], row["connected_company_name"]])
|
||||
|
@ -13,11 +13,7 @@ class CompanyMongoService:
|
||||
"""Wrapper for MongoDB regarding management of Company documents."""
|
||||
|
||||
def __init__(self, connector: MongoConnector):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
connector (MongoConnector): _description_
|
||||
"""
|
||||
"""Constructor."""
|
||||
self.collection = connector.database["companies"]
|
||||
self.lock = Lock() # Create a lock for synchronization
|
||||
|
||||
@ -137,14 +133,7 @@ class CompanyMongoService:
|
||||
return malformed_entries
|
||||
|
||||
def insert(self, company: Company) -> InsertOneResult:
|
||||
"""Insert a new Company document.
|
||||
|
||||
Args:
|
||||
company (Company): _description_
|
||||
|
||||
Returns:
|
||||
_description_
|
||||
"""
|
||||
"""Insert a new Company document."""
|
||||
with self.lock:
|
||||
return self.collection.insert_one(company.to_dict())
|
||||
|
||||
|
@ -9,11 +9,7 @@ class MongoNewsService:
|
||||
"""Wrapper for MongoDB regarding News documents."""
|
||||
|
||||
def __init__(self, connector: MongoConnector):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
connector (MongoConnector): _description_
|
||||
"""
|
||||
"""Constructor."""
|
||||
self.collection = connector.database["news"]
|
||||
|
||||
def get_all(self) -> list[News]:
|
||||
|
@ -1,8 +1,10 @@
|
||||
"""Module to receive and filter Data for working with NetworkX."""
|
||||
import os
|
||||
from functools import lru_cache
|
||||
|
||||
import networkx as nx
|
||||
import pandas as pd
|
||||
from cachetools import TTLCache, cached
|
||||
from sqlalchemy.orm import aliased
|
||||
|
||||
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
|
||||
@ -24,12 +26,11 @@ COLOR_COMPANY = "#006250"
|
||||
COLOR_PERSON = "#ff5200"
|
||||
|
||||
|
||||
@cached( # type: ignore
|
||||
cache=TTLCache(maxsize=100, ttl=int(os.getenv("PYTHON_CACHE_TTL", "3600")))
|
||||
)
|
||||
def find_all_company_relations() -> pd.DataFrame:
|
||||
"""_summary_.
|
||||
|
||||
Returns:
|
||||
pd.DataFrame: _description_
|
||||
"""
|
||||
"""_summary_."""
|
||||
session = SessionHandler.session
|
||||
assert session # noqa: S101
|
||||
query_companies = session.query(entities.Company) # .all()
|
||||
@ -64,7 +65,7 @@ def find_all_company_relations() -> pd.DataFrame:
|
||||
|
||||
|
||||
def get_all_company_relations() -> pd.DataFrame:
|
||||
"""This Methods makes a Database Request for all Companies and their relations, modifies the ID Column and returns the Result as an DataFrame.
|
||||
"""Makes a Database Request for all Companies and their relations, modifies the ID Column and returns the Result as an DataFrame.
|
||||
|
||||
Returns:
|
||||
DataFrame: DataFrame with all Relations between Companies.
|
||||
@ -102,7 +103,11 @@ def get_all_company_relations() -> pd.DataFrame:
|
||||
return company_relations
|
||||
|
||||
|
||||
def get_all_person_relations() -> pd.DataFrame:
|
||||
@cached( # type: ignore
|
||||
cache=TTLCache(maxsize=100, ttl=int(os.getenv("PYTHON_CACHE_TTL", "3600"))),
|
||||
key=lambda drop_min_person_links: hash(drop_min_person_links),
|
||||
)
|
||||
def get_all_person_relations(drop_min_person_links: bool) -> pd.DataFrame:
|
||||
"""These method makes a Database Request for all Persons and their relations, modifies the ID Column and returns the Result as an DataFrame.
|
||||
|
||||
Returns:
|
||||
@ -137,7 +142,8 @@ def get_all_person_relations() -> pd.DataFrame:
|
||||
person_relations["id_person"] = person_relations["id_person"].apply(
|
||||
lambda x: f"p_{x}"
|
||||
)
|
||||
|
||||
if drop_min_person_links:
|
||||
return person_relations.groupby("id_person").filter(lambda x: len(x) > 1)
|
||||
return person_relations
|
||||
|
||||
|
||||
@ -163,15 +169,7 @@ def filter_relation_type(
|
||||
def create_edge_and_node_list(
|
||||
person_relations: pd.DataFrame, company_relations: pd.DataFrame
|
||||
) -> tuple[dict, list]:
|
||||
"""In this Method the given DataFrames with the relation will be morphed to Edge and Node lists and enhanced by a coloring for companies and person Nodes.
|
||||
|
||||
Args:
|
||||
person_relations (pd.DataFrame): _description_
|
||||
company_relations (pd.DataFrame): _description_
|
||||
|
||||
Returns:
|
||||
_description_
|
||||
"""
|
||||
"""In this Method the given DataFrames with the relation will be morphed to Edge and Node lists and enhanced by a coloring for companies and person Nodes."""
|
||||
nodes: dict = {}
|
||||
edges: list = []
|
||||
|
||||
@ -332,15 +330,7 @@ def find_person_relations(
|
||||
def create_edge_and_node_list_for_company(
|
||||
company_relations: pd.DataFrame,
|
||||
) -> tuple[dict, list]:
|
||||
"""In this Method the given DataFrames with the relation will be morphed to Edge and Node lists and enhanced by a coloring for companies and person Nodes.
|
||||
|
||||
Args:
|
||||
person_relations (pd.DataFrame): _description_
|
||||
company_relations (pd.DataFrame): _description_
|
||||
|
||||
Returns:
|
||||
_description_
|
||||
"""
|
||||
"""In this Method the given DataFrames with the relation will be morphed to Edge and Node lists and enhanced by a coloring for companies and person Nodes."""
|
||||
nodes: dict = {}
|
||||
edges: list = []
|
||||
|
||||
@ -374,12 +364,9 @@ def get_all_metrics_from_id(company_id: int) -> pd.Series:
|
||||
|
||||
Args:
|
||||
company_id (int): Id of the Company.
|
||||
|
||||
Returns:
|
||||
pd.DataFrame: _description_
|
||||
"""
|
||||
# Get Data
|
||||
person_df = get_all_person_relations()
|
||||
person_df = get_all_person_relations(False)
|
||||
company_df = get_all_company_relations()
|
||||
|
||||
# Create Edge and Node List from data
|
||||
@ -412,11 +399,9 @@ def get_relations_number_from_id(id: str) -> tuple[int, int, int]:
|
||||
Args:
|
||||
id: String of the Company or Person Id.
|
||||
|
||||
Returns:
|
||||
tuple[int,int,int]: _description_
|
||||
"""
|
||||
# Get Data
|
||||
person_df = get_all_person_relations()
|
||||
person_df = get_all_person_relations(False)
|
||||
company_df = get_all_company_relations()
|
||||
|
||||
# Create Edge and Node List from data
|
||||
@ -457,7 +442,7 @@ def get_relations_until_level_3(id: str) -> tuple[dict, list]:
|
||||
tuple[dict, list]: nodes, edges
|
||||
"""
|
||||
# Get Data
|
||||
person_df = get_all_person_relations()
|
||||
person_df = get_all_person_relations(False)
|
||||
company_df = get_all_company_relations()
|
||||
|
||||
# Create Edge and Node List from data
|
||||
|
Loading…
x
Reference in New Issue
Block a user