feat: apply rel-001 feedback cleanup
This commit is contained in:
@@ -19,6 +19,7 @@ class HealthResponse(BaseModel):
|
||||
service: str
|
||||
version: str
|
||||
checked_at: str
|
||||
db_enabled: bool
|
||||
|
||||
|
||||
@router.get("/health", response_model=HealthResponse)
|
||||
@@ -29,4 +30,5 @@ def healthcheck() -> HealthResponse:
|
||||
service="portfolio-hub",
|
||||
version=settings.app_version,
|
||||
checked_at=datetime.now(_KST).isoformat(),
|
||||
db_enabled=settings.db_enabled,
|
||||
)
|
||||
|
||||
@@ -545,7 +545,7 @@ def record_ledger_trade_v1(
|
||||
)
|
||||
|
||||
trade, created = repo.insert_ledger_trade(
|
||||
asset_id=portfolio_id,
|
||||
portfolio_id=portfolio_id,
|
||||
order_id=body.order_id,
|
||||
execution_id=body.execution_id,
|
||||
side=body.side,
|
||||
@@ -573,7 +573,7 @@ def record_ledger_trade_v1(
|
||||
|
||||
return LedgerTradeResponse(
|
||||
ledger_entry_id=trade.ledger_entry_id,
|
||||
asset_id=trade.asset_id,
|
||||
portfolio_id=trade.portfolio_id,
|
||||
order_id=trade.order_id,
|
||||
execution_id=trade.execution_id,
|
||||
side=trade.side,
|
||||
|
||||
@@ -174,7 +174,7 @@ class BrokerCredential:
|
||||
@dataclass
|
||||
class LedgerTrade:
|
||||
ledger_entry_id: int
|
||||
asset_id: str
|
||||
portfolio_id: str
|
||||
order_id: str
|
||||
execution_id: str
|
||||
side: str
|
||||
|
||||
@@ -253,7 +253,7 @@ class PortfolioRepository(Protocol):
|
||||
def insert_ledger_trade(
|
||||
self,
|
||||
*,
|
||||
asset_id: str,
|
||||
portfolio_id: str,
|
||||
order_id: str,
|
||||
execution_id: str,
|
||||
side: str,
|
||||
|
||||
@@ -1267,7 +1267,7 @@ class PostgresPortfolioRepository:
|
||||
def insert_ledger_trade(
|
||||
self,
|
||||
*,
|
||||
asset_id: str,
|
||||
portfolio_id: str,
|
||||
order_id: str,
|
||||
execution_id: str,
|
||||
side: str,
|
||||
@@ -1282,17 +1282,17 @@ class PostgresPortfolioRepository:
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO ledger_trades
|
||||
(asset_id, order_id, execution_id, side, quantity, price,
|
||||
(portfolio_id, order_id, execution_id, side, quantity, price,
|
||||
fee_amount, tax_amount, executed_at)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
ON CONFLICT ON CONSTRAINT uq_ledger_trades_idempotency DO NOTHING
|
||||
RETURNING
|
||||
ledger_entry_id, asset_id, order_id, execution_id, side,
|
||||
ledger_entry_id, portfolio_id, order_id, execution_id, side,
|
||||
quantity::float8, price::float8,
|
||||
fee_amount::float8, tax_amount::float8,
|
||||
executed_at, recorded_at
|
||||
""",
|
||||
(asset_id, order_id, execution_id, side, quantity, price,
|
||||
(portfolio_id, order_id, execution_id, side, quantity, price,
|
||||
fee_amount, tax_amount, executed_at),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
@@ -1302,14 +1302,14 @@ class PostgresPortfolioRepository:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
ledger_entry_id, asset_id, order_id, execution_id, side,
|
||||
ledger_entry_id, portfolio_id, order_id, execution_id, side,
|
||||
quantity::float8, price::float8,
|
||||
fee_amount::float8, tax_amount::float8,
|
||||
executed_at, recorded_at
|
||||
FROM ledger_trades
|
||||
WHERE asset_id = %s AND order_id = %s AND execution_id = %s
|
||||
WHERE portfolio_id = %s AND order_id = %s AND execution_id = %s
|
||||
""",
|
||||
(asset_id, order_id, execution_id),
|
||||
(portfolio_id, order_id, execution_id),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
return self._row_to_ledger_trade(row), False
|
||||
@@ -1319,7 +1319,7 @@ class PostgresPortfolioRepository:
|
||||
from app.domain.models import LedgerTrade
|
||||
return LedgerTrade(
|
||||
ledger_entry_id=row[0],
|
||||
asset_id=row[1],
|
||||
portfolio_id=row[1],
|
||||
order_id=row[2],
|
||||
execution_id=row[3],
|
||||
side=row[4],
|
||||
|
||||
+3
-1
@@ -5,12 +5,14 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
from app.schemas.user import UserResponse
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
username: str = Field(min_length=1)
|
||||
password: str = Field(min_length=1)
|
||||
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ class LedgerTradeRequest(BaseModel):
|
||||
|
||||
class LedgerTradeResponse(BaseModel):
|
||||
ledger_entry_id: int
|
||||
asset_id: str
|
||||
portfolio_id: str
|
||||
order_id: str
|
||||
execution_id: str
|
||||
side: str
|
||||
|
||||
Reference in New Issue
Block a user