Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rag-reviewer",
"version": "0.3.2+codex.9d551e36d655",
"version": "0.3.3+codex.9aa7a5c3958b",
"description": "Agentic PR review: hybrid RAG + code graph via MCP, review skills for Codex",
"repository": "https://github.com/mimfort/rag_for_git",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion plugin/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rag-reviewer",
"version": "0.3.2",
"version": "0.3.3",
"description": "Agentic PR review: hybrid RAG + code graph via MCP, review skills for Claude Code"
}
2 changes: 1 addition & 1 deletion plugin/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rag-reviewer",
"version": "0.3.2+codex.9d551e36d655",
"version": "0.3.3+codex.9aa7a5c3958b",
"description": "Agentic PR review: hybrid RAG + code graph via MCP, review skills for Codex",
"repository": "https://github.com/mimfort/rag_for_git",
"license": "MIT",
Expand Down
30 changes: 16 additions & 14 deletions reviewer/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
def create_app(settings: Settings) -> FastAPI:
"""Создать и настроить FastAPI-приложение.

- Инициализирует ReviewHistory и schema (fail-soft: если БД недоступна,
сервер всё равно стартует с предупреждением).
- Инициализирует ReviewHistory; схема создаётся на старте сервера в lifespan
(fail-soft: если БД недоступна, сервер всё равно стартует с предупреждением).
- Монтирует API-роутер (/api/*).
- Монтирует собранный SPA на / (если dist существует) или отдаёт заглушку.
- Настраивает CORS для dev-сервера Vite (:5173).
- При завершении работы закрывает пул соединений к Postgres.

Пул Postgres создаётся лениво (init_schema — в lifespan, не в теле фабрики),
поэтому простое конструирование приложения к БД не подключается.
"""
history = ReviewHistory(
settings.pg_dsn,
Expand All @@ -48,6 +51,16 @@ def create_app(settings: Settings) -> FastAPI:

@asynccontextmanager
async def _lifespan(app: FastAPI):
# История прогонов: инициализация схемы на старте (fail-soft).
try:
history.init_schema()
except Exception as exc:
log.warning(
"Не удалось инициализировать схему БД истории (%s). "
"Убедитесь, что Postgres запущен: docker compose up -d. "
"API-эндпоинты вернут ошибку 500 до подключения к БД.",
exc,
)
yield
history.close()

Expand All @@ -67,18 +80,7 @@ async def _lifespan(app: FastAPI):
allow_headers=["*"],
)

# История прогонов
try:
history.init_schema()
except Exception as exc:
log.warning(
"Не удалось инициализировать схему БД истории (%s). "
"Убедитесь, что Postgres запущен: docker compose up -d. "
"API-эндпоинты вернут ошибку 500 до подключения к БД.",
exc,
)

# API-роутер
# API-роутер (схема БД инициализируется в lifespan на старте сервера)
app.include_router(make_router(history, settings))

# Статика / SPA
Expand Down