generated from dopt-python/py311
additional logging and error handling
This commit is contained in:
@@ -8,6 +8,7 @@ import polars as pl
|
||||
import sqlalchemy as sql
|
||||
|
||||
from wce_crm import db
|
||||
from wce_crm.logging import logger_back as logger
|
||||
|
||||
|
||||
class CompanyInfo(TypedDict):
|
||||
@@ -83,6 +84,7 @@ def _transform_for_gui_output(
|
||||
|
||||
def comp_search_choices() -> tuple[tuple[str, int], ...]:
|
||||
# TODO no reload functionality
|
||||
logger.debug("[Call backend] comp_search_choices")
|
||||
q = db.DF_CRM_MASTER.lazy()
|
||||
counter = pl.int_range(0, pl.len()).over(pl.col.ma_unternehmensname)
|
||||
q = q.with_columns(
|
||||
@@ -98,6 +100,7 @@ def comp_search_choices() -> tuple[tuple[str, int], ...]:
|
||||
def comp_search_get_info(
|
||||
ma_id: int,
|
||||
) -> CompanyInfo:
|
||||
logger.debug("[Call backend] comp_search_get_info")
|
||||
df = db.DF_CRM_MASTER.filter(pl.col.ma_id == ma_id)
|
||||
if df.height > 1 or df.height == 0:
|
||||
raise ValueError(f"Größe des zurückgelieferten Datenpakets ungültig: {df.height}")
|
||||
@@ -111,6 +114,7 @@ def contact_person_search_choices(
|
||||
use_both_names: bool,
|
||||
) -> tuple[tuple[str, int], ...]:
|
||||
# TODO no reload functionality
|
||||
logger.debug("[Call backend] contact_person_search_choices")
|
||||
q = db.DF_CONTACT_PERSON.lazy()
|
||||
if ma_id is not None:
|
||||
q = q.filter(pl.col.ma_id == ma_id)
|
||||
@@ -136,6 +140,7 @@ def contact_person_search_choices(
|
||||
def contact_person_search_get_info(
|
||||
an_id: int,
|
||||
) -> ContactPersonInfo:
|
||||
logger.debug("[Call backend] contact_person_search_get_info")
|
||||
df = db.DF_CONTACT_PERSON.filter(pl.col.an_id == an_id)
|
||||
if df.height > 1 or df.height == 0:
|
||||
raise ValueError(f"Größe des zurückgelieferten Datenpakets ungültig: {df.height}")
|
||||
@@ -147,6 +152,7 @@ def contact_person_search_get_info(
|
||||
def insert_initial_recording(
|
||||
data: dict[str, Any],
|
||||
) -> None:
|
||||
logger.debug("[Call backend] insert_initial_recording")
|
||||
stmt = db.grunderfassung_unternehmen.insert().values(data)
|
||||
with db.ENGINE.begin() as conn:
|
||||
conn.execute(stmt)
|
||||
@@ -156,6 +162,7 @@ def update_initial_recording(
|
||||
id_: int,
|
||||
data: dict[str, Any],
|
||||
) -> None:
|
||||
logger.debug("[Call backend] update_initial_recording")
|
||||
stmt = (
|
||||
db.grunderfassung_unternehmen.update()
|
||||
.where(db.grunderfassung_unternehmen.c.erfassung_id == id_)
|
||||
@@ -168,6 +175,7 @@ def update_initial_recording(
|
||||
def get_initial_recording(
|
||||
id_: int,
|
||||
) -> dict[str, Any]:
|
||||
logger.debug("[Call backend] get_initial_recording")
|
||||
stmt = db.grunderfassung_unternehmen.select().where(
|
||||
db.grunderfassung_unternehmen.c.erfassung_id == id_
|
||||
)
|
||||
@@ -190,6 +198,7 @@ class FrontpageCompany:
|
||||
|
||||
|
||||
def get_company_list() -> list[FrontpageCompany]:
|
||||
logger.debug("[Call backend] get_company_list")
|
||||
stmt = sql.select(
|
||||
db.grunderfassung_unternehmen.c.erfassung_id,
|
||||
db.grunderfassung_unternehmen.c.Partnersuche__un_suche,
|
||||
|
||||
Reference in New Issue
Block a user