feat(sf-b3): POST /pilot/request — lead gen + pilot_requests table (Telegram TODO) #330
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#330
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/sf-b3-pilot-leads"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
SF Wave 1 / Group B / sub-task B3 из SiteFinder Backend Migration Plan May17.
Files
backend/app/api/v1/pilot.py— NEW router сPOST /api/v1/pilot/requestbackend/app/main.py—app.include_router(pilot.router, prefix="/api/v1/pilot", tags=["pilot"])data/sql/118_pilot_requests.sql— NEW migration:pilot_requeststable + index + commentSchema
API
POST /api/v1/pilot/requestпринимает{name, phone?, email?, company?, message?, source?}→ INSERT → returns{id, created_at, status: "received"}.Telegram notification — TODO (нужны
TELEGRAM_BOT_TOKEN+TELEGRAM_CHAT_IDcreds, добавится follow-up).Test plan
POST /api/v1/pilot/request{"name": "Test", "source": "landing"}→ 200 + idpilot_requestsPart of plan vault
code/patterns/SiteFinder_Backend_Migration_Plan_May17.md§B3.Добавляет endpoint для приёма заявок на пилот (lead-gen). INSERT в pilot_requests, response {id, created_at, status}. Telegram-уведомление — TODO (creds не настроены, #307 SF-B3). Migration: data/sql/118_pilot_requests.sqlDeep Code Review — APPROVE
Migration
data/sql/118_pilot_requests.sqlBEGIN/COMMITwrapper,CREATE TABLE IF NOT EXISTS,CREATE INDEX IF NOT EXISTS— idempotentgen_random_uuid()— PG 13+ core function, не требуетpgcrypto(уже используется в91_engineering_networks_191fz.sqlи115_trade_in_estimates.sqlна prod безCREATE EXTENSION— empirical confirmation)(created_at DESC)подходит под обычные admin list-queriesCOMMENT ON TABLEpresent, нет DROP/TRUNCATE118— следующий после 117 ✓Endpoint
backend/app/api/v1/pilot.pynamemin_length=2, max_length=200,phone max_length=50,company max_length=200,message max_length=2000— DoS payload caps уже на местеEmailStr(validated) +Literal["landing","analyze_page","other"]дляsource— strong validationtext(...)+ bind params, нет injectionCAST(id AS text)— psycopg v3 / SQLAlchemy 2.0 convention compliant (никаких::text)Session+.mappings().one()+db.commit()matchesget_db()semanticslogger.info(...), нетprint, нетrequests, нетimport psycopg2, нет hardcoded credsmain.py wiring
prefix="/api/v1/pilot"+ router/request→/api/v1/pilot/request✓Cross-file impact
Self-contained NEW router + NEW table + 2 line registration. Нет callers для обновления, frontend types не затронуты.
Non-blocking follow-ups
max_lengthограничивает payload size.user_agenttext не имеетmax_length— теоретически browser может прислать длинный UA. Маловероятно abuse, ноmax_length=512был бы дешёвой страховкой. Не блокирующее.Risk
Merging.
⚠️ Merge blocked: conflict with main after PR #329 merge.
Both #329 and #330 add
app.include_router(...)inbackend/app/main.py→ conflict in the router registration block.update_pr_branchreturned409: merge failed because of conflict. Conflict resolution needed by author —backend/app/main.pyshould keep BOTHinclude_router(users.router, ...)andinclude_router(pilot.router, ...)lines.Code review verdict stands as ✅ APPROVE — will retry merge automatically on next polling iteration once branch is updated.