From 981d3ea9330c4526af90f8af6824e35bc3885331 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 25 Sep 2025 10:20:37 -0500 Subject: [PATCH] Fixes in. Hooray. --- crudkit/core/service.py | 3 --- crudkit/integrations/flask.py | 26 -------------------------- inventory/__init__.py | 21 --------------------- inventory/routes/index.py | 6 ++---- inventory/routes/listing.py | 6 ------ 5 files changed, 2 insertions(+), 60 deletions(-) diff --git a/crudkit/core/service.py b/crudkit/core/service.py index 262499d..8307c11 100644 --- a/crudkit/core/service.py +++ b/crudkit/core/service.py @@ -245,7 +245,6 @@ class CRUDService(Generic[T]): - forward/backward seek via `key` and `backward` Returns a SeekWindow with items, first/last keys, order spec, limit, and optional total. """ - self._debug_bind("seek_window") session = self.session query, root_alias = self.get_query() @@ -477,7 +476,6 @@ class CRUDService(Generic[T]): def get(self, id: int, params=None) -> T | None: """Fetch a single row by id with conflict-free eager loading and clean projection.""" - self._debug_bind("get") query, root_alias = self.get_query() # Defaults so we can build a projection even if params is None @@ -572,7 +570,6 @@ class CRUDService(Generic[T]): def list(self, params=None) -> list[T]: """Offset/limit listing with smart relationship loading and clean projection.""" - self._debug_bind("list") query, root_alias = self.get_query() # Defaults so we can reference them later even if params is None diff --git a/crudkit/integrations/flask.py b/crudkit/integrations/flask.py index 433f6a5..feb262b 100644 --- a/crudkit/integrations/flask.py +++ b/crudkit/integrations/flask.py @@ -26,32 +26,6 @@ def init_app(app: Flask, *, runtime: CRUDKitRuntime | None = None, config: type[ try: bound_engine = getattr(SessionFactory, "bind", None) or getattr(SessionFactory, "kw", {}).get("bind") or engine pool = bound_engine.pool - - from sqlalchemy import event - - @event.listens_for(pool, "checkout") - def _on_checkout(dbapi_conn, conn_record, conn_proxy): - sz = pool.size() - chk = pool.checkedout() - try: - conns_in_pool = pool.checkedin() - except Exception: - conns_in_pool = "?" - print(f"POOL CHECKOUT: Pool size: {sz} Connections in pool: {conns_in_pool} " - f"Current Overflow: {pool.overflow()} Current Checked out connections: {chk} " - f"engine id= {id(bound_engine)}") - - @event.listens_for(pool, "checkin") - def _on_checkin(dbapi_conn, conn_record): - sz = pool.size() - chk = pool.checkedout() - try: - conns_in_pool = pool.checkedin() - except Exception: - conns_in_pool = "?" - print(f"POOL CHECKIN: Pool size: {sz} Connections in pool: {conns_in_pool} " - f"Current Overflow: {pool.overflow()} Current Checked out connections: {chk} " - f"engine id= {id(bound_engine)}") except Exception as e: print(f"[crudkit.init_app] Failed to attach pool listeners: {e}") diff --git a/inventory/__init__.py b/inventory/__init__.py index 484196d..3e8f6d7 100644 --- a/inventory/__init__.py +++ b/inventory/__init__.py @@ -15,25 +15,6 @@ from .routes.index import init_index_routes from .routes.listing import init_listing_routes from .routes.entry import init_entry_routes -def _bind_pool_debug(engine): - pool = engine.pool - eid = id(engine) - - @event.listens_for(pool, "checkout") - def _on_checkout(dbapi_con, con_record, con_proxy): - try: - print(f"POOL CHECKOUT: {pool.status()} engine id= {eid}") - except Exception: - # pool.status is safe on SQLA 2.x, but let's be defensive - print(f"POOL CHECKOUT (no status) engine id= {eid}") - - @event.listens_for(pool, "checkin") - def _on_checkin(dbapi_con, con_record): - try: - print(f"POOL CHECKIN: {pool.status()} engine id= {eid}") - except Exception: - print(f"POOL CHECKIN (no status) engine id= {eid}") - def create_app(config_cls=crudkit.DevConfig) -> Flask: app = Flask(__name__) @@ -43,8 +24,6 @@ def create_app(config_cls=crudkit.DevConfig) -> Flask: from sqlalchemy import event engine = runtime.engine - print(f"CRUDKit engine id={id(runtime.engine)} url={runtime.engine.url}") - _bind_pool_debug(runtime.engine) # ← attach to the real engine’s pool # quick status endpoint you can hit while clicking around @app.get("/_db_status") diff --git a/inventory/routes/index.py b/inventory/routes/index.py index c9391b1..fc4191b 100644 --- a/inventory/routes/index.py +++ b/inventory/routes/index.py @@ -22,8 +22,7 @@ def init_index_routes(app): "fields": [ "start_time", "contact.label", - "work_item.label", - "work_item.device_type.description" + "work_item.label" ], "sort": "start_time" }) @@ -65,8 +64,7 @@ def init_index_routes(app): {"field": "contact.label", "label": "Contact", "link": {"endpoint": "entry.entry", "params": {"id": "{contact.id}", "model": "user"}}}, {"field": "work_item.label", "label": "Work Item", - "link": {"endpoint": "entry.entry", "params": {"id": "{work_item.id}", "model": "inventory"}}}, - {"field": "work_item.device_type.description", "label": "Device Type"} + "link": {"endpoint": "entry.entry", "params": {"id": "{work_item.id}", "model": "inventory"}}} ] logs = render_table(work_logs, columns=columns, opts={"object_class": "worklog"}) diff --git a/inventory/routes/listing.py b/inventory/routes/listing.py index 389851c..830ddb2 100644 --- a/inventory/routes/listing.py +++ b/inventory/routes/listing.py @@ -125,12 +125,6 @@ def init_listing_routes(app): except Exception: svc_engine = None - print( - "LISTING ENGINES: " - f"runtime={id(rt_engine) if rt_engine else None} " - f"session_factory.bind={id(sf_engine) if sf_engine else None} " - f"service.bind={id(svc_engine) if svc_engine else None}" - ) # include limit and go window = service.seek_window(spec | {"limit": limit}, key=key, backward=backward, include_total=True)