Skip to content

Commit 4292a06

Browse files
committed
Move queue import handlers to import_ package
Reorganize import-related endpoints into a dedicated import_ package. Added package markers (__init__.py) and a placeholder README, moved the existing linkedin importer into app/api/queue/import_ and updated the queue router import paths accordingly. Also added a new apollo.py stub endpoint (/queue/import/apollo) that provides a template for CSV import (includes TODOs for CSV parsing and DB insertion). No functional import logic implemented yet; this change is primarily structural to group import handlers.
1 parent 7d7a35c commit 4292a06

6 files changed

Lines changed: 34 additions & 3 deletions

File tree

app/api/queue/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from .routes.create import router as create_router
1010
from .routes.delete import router as delete_router
1111

12-
from .routes.import_linkedin import router as import_linkedin_router
13-
12+
from .import_ import linkedin as linkedin_import_router
1413
from .routes.alter import router as alter_router
1514
from .routes.rename_column import router as rename_router
1615

@@ -20,6 +19,6 @@
2019
router.include_router(get_router)
2120
router.include_router(create_router)
2221
router.include_router(delete_router)
23-
router.include_router(import_linkedin_router)
22+
router.include_router(linkedin_import_router.router)
2423
router.include_router(alter_router)
2524
router.include_router(rename_router)

app/api/queue/import/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Makes this directory a Python package

app/api/queue/import_/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Placeholder for migration

app/api/queue/import_/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Makes this directory a Python package

app/api/queue/import_/apollo.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import csv
3+
import time
4+
from fastapi import APIRouter, HTTPException
5+
from app.utils.make_meta import make_meta
6+
from app.utils.db import get_db_connection_direct
7+
8+
router = APIRouter()
9+
10+
@router.post("/queue/import/apollo")
11+
def import_apollo_csv() -> dict:
12+
"""POST /queue/import/apollo: Import data from apollo.csv into the queue table (template)."""
13+
csv_path = os.path.join(os.path.dirname(__file__), "../csv/apollo/seed.csv")
14+
if not os.path.exists(csv_path):
15+
raise HTTPException(status_code=404, detail="seed.csv not found")
16+
try:
17+
conn = get_db_connection_direct()
18+
cursor = conn.cursor()
19+
# TODO: Implement CSV parsing and DB insertion logic for Apollo format
20+
# Example placeholder for batch import logic:
21+
# with open(csv_path, newline='', encoding='utf-8') as csvfile:
22+
# reader = csv.DictReader(csvfile)
23+
# for row in reader:
24+
# pass # Process each row
25+
conn.commit()
26+
conn.close()
27+
return {"meta": make_meta("success", "Apollo CSV import template executed"), "imported": 0}
28+
except Exception as e:
29+
raise HTTPException(status_code=500, detail=str(e))

0 commit comments

Comments
 (0)