From 7f11e129ee7766a290e608cbaa0e720b4ad568e5 Mon Sep 17 00:00:00 2001 From: Goldlabel Apps Ltd Date: Mon, 23 Mar 2026 21:17:22 +0000 Subject: [PATCH 1/3] Update root.py --- app/api/root.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/root.py b/app/api/root.py index 20a45aa..ae673ee 100644 --- a/app/api/root.py +++ b/app/api/root.py @@ -13,8 +13,8 @@ def root() -> dict: base_url = os.getenv("BASE_URL", "http://localhost:8000") epoch = int(time.time() * 1000) meta = { + "title": "How can I help?", "severity": "success", - "title": "How can NX-AI help?", "version": __version__, "base_url": base_url, "time": epoch, From b115b527c3bc7433e15ab212af92093bbe1ca1f0 Mon Sep 17 00:00:00 2001 From: Goldlabel Apps Ltd Date: Mon, 23 Mar 2026 21:27:58 +0000 Subject: [PATCH 2/3] Rename project to 'I' and bump version Rebrand project from 'NX-AI' to 'I': update CI workflow name, README title, Render project name, and FastAPI app title/description. Bump package version to 1.1.1. Update tests' docstrings to reflect the new naming and messaging. --- .github/workflows/ci.yml | 2 +- README.md | 2 +- app/__init__.py | 2 +- app/main.py | 6 ++---- render.yaml | 2 +- tests/test_routes.py | 4 ++-- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41c1b91..9303140 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: 🍴 NX-API TEST +name: 🍴 I TEST on: push: diff --git a/README.md b/README.md index 1ffa2aa..74aa716 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Python NX AI +## I > FastAPI/Python/Postgres/tsvector. Open Source, production ready Python FastAPI/Postgres app for [NX](https://goldlabel.pro?s=python-nx-ai) diff --git a/app/__init__.py b/app/__init__.py index 21735b6..de3a844 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,4 +1,4 @@ """NX AI - FastAPI/Python/Postgres/tsvector""" # Current Version -__version__ = "1.1.0" +__version__ = "1.1.1" diff --git a/app/main.py b/app/main.py index cb8a86a..131f17b 100644 --- a/app/main.py +++ b/app/main.py @@ -4,13 +4,11 @@ from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse import os - -from app import __version__ from app.api.routes import router app = FastAPI( - title="NX-AI", - description="Production-ready Python FastAPI app for NX", + title="I", + description="Production-ready Python with FastAPI and tsvector", version=__version__, ) diff --git a/render.yaml b/render.yaml index 9769557..4a2a342 100644 --- a/render.yaml +++ b/render.yaml @@ -1,7 +1,7 @@ # Exported from Render on 2026-03-18T18:57:52Z version: "1" projects: -- name: NX AI Python +- name: I environments: - name: Production services: diff --git a/tests/test_routes.py b/tests/test_routes.py index b9f1672..0bf8cf9 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -1,4 +1,4 @@ -"""Unit and integration tests for NX AI routes.""" +"""Unit and integration tests for I endpoints.""" from unittest.mock import MagicMock from fastapi.testclient import TestClient @@ -8,7 +8,7 @@ client = TestClient(app) def test_root_returns_welcome_message() -> None: - """GET / should return a welcome message.""" + """GET / should reply in the first person.""" response = client.get("/") assert response.status_code == 200 json_data = response.json() From b8ce5e217293de6488708541a39bc4c0c78e58ff Mon Sep 17 00:00:00 2001 From: Goldlabel Apps Ltd Date: Mon, 23 Mar 2026 21:52:21 +0000 Subject: [PATCH 3/3] Add /products/update endpoint and routing Introduce a new endpoint at GET /products/update (202 Accepted) implemented in app/api/products/update.py that processes data/big_data.csv and updates the product table (matching item or EAN) using get_db_connection. The handler returns a meta payload with version, base_url and timestamp. Wire the new router into app/api/routes.py and add a link to the new update route in the root API listing (app/api/root.py). --- app/api/products/update.py | 59 ++++++++++++++++++++++++++++++++++++++ app/api/root.py | 3 +- app/api/routes.py | 2 ++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 app/api/products/update.py diff --git a/app/api/products/update.py b/app/api/products/update.py new file mode 100644 index 0000000..c14a456 --- /dev/null +++ b/app/api/products/update.py @@ -0,0 +1,59 @@ +from fastapi import APIRouter, status +import os, csv, time +from app.api.db import get_db_connection +from app import __version__ + +router = APIRouter() + +@router.get("/products/update", status_code=status.HTTP_202_ACCEPTED) +def update_products() -> dict: + """Process the large big_data.csv file to update products.""" + csv_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data/big_data.csv')) + process_csv(csv_path) + base_url = os.getenv("BASE_URL", "http://localhost:8000") + epoch = int(time.time() * 1000) + meta = { + "severity": "info", + "title": "Product update from big_data.csv started", + "version": __version__, + "base_url": base_url, + "time": epoch, + } + return {"meta": meta, "data": {"filename": "big_data.csv"}} + +def process_csv(csv_path: str): + conn_gen = get_db_connection() + conn = next(conn_gen) + cur = conn.cursor() + with open(csv_path, newline='') as csvfile: + reader = csv.DictReader(csvfile) + for row in reader: + cur.execute( + """ + UPDATE product SET + Params=%(Params)s, + title=%(desc)s, + UOS=%(UOS)s, + Pack_Description=%(Pack_Description)s, + Hierarchy1=%(Hierarchy1)s, + Hierarchy2=%(Hierarchy2)s, + Hierarchy3=%(Hierarchy3)s, + UOP=%(UOP)s, + sSell1=%(sSell1)s, + sSell2=%(sSell2)s, + sSell3=%(sSell3)s, + sSell4=%(sSell4)s, + sSell5=%(sSell5)s, + pack1=%(pack1)s, + pack2=%(pack2)s, + pack3=%(pack3)s, + pack4=%(pack4)s, + pack5=%(pack5)s, + EAN=%(EAN)s + WHERE item=%(item)s OR EAN=%(EAN)s + """, + row + ) + conn.commit() + cur.close() + conn.close() diff --git a/app/api/root.py b/app/api/root.py index ae673ee..259f96d 100644 --- a/app/api/root.py +++ b/app/api/root.py @@ -26,7 +26,8 @@ def root() -> dict: "name": "products", "url": f"{base_url}/products", "children": [ - {"name": "seed", "url": f"{base_url}/products/seed"} + {"name": "seed", "url": f"{base_url}/products/seed"}, + {"name": "update", "url": f"{base_url}/products/update"} ] } ] diff --git a/app/api/routes.py b/app/api/routes.py index ec04a6f..61067ba 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -14,8 +14,10 @@ from app.api.health import router as health_router from app.api.products.products import router as products_router from app.api.products.seed import router as seed_router +from app.api.products.update import router as update_router router.include_router(root_router) router.include_router(health_router) router.include_router(products_router) router.include_router(seed_router) +router.include_router(update_router)