feat: add portfolio daemon assignment and improve list rendering

- Add --daemon-id option to portfolio update command for daemon assignment
- Update managed_by_daemon_id field in portfolio updates
- Refactor print_portfolio_table() to print_portfolio_list() for better readability
- Display daemon_id in portfolio list output when assigned
- Show portfolio tags and managed daemon information in CLI list view
- Add daemon_id support to portfolio repository and service layers
- Update schemas to include managed_by_daemon_id field in responses
This commit is contained in:
2026-05-15 08:27:14 +00:00
parent d194873616
commit b9e3bddb34
7 changed files with 43 additions and 27 deletions
+2
View File
@@ -112,6 +112,8 @@ class PortfolioRepository(Protocol):
def get(self, portfolio_id: str) -> Portfolio: ...
def get_portfolio_by_name_and_user(self, owner_user_id: str, name: str) -> Portfolio | None: ...
def get_or_create(
self,
portfolio_id: str,
+15
View File
@@ -743,6 +743,20 @@ class PostgresPortfolioRepository:
self._attach_tags(cur, [portfolio])
return portfolio
def get_portfolio_by_name_and_user(self, owner_user_id: str, name: str) -> Portfolio | None:
self.ensure_schema()
with self._connect().cursor() as cur:
cur.execute(
_SELECT_PORTFOLIO + "WHERE owner_user_id = %s AND name = %s",
(owner_user_id, name),
)
row = cur.fetchone()
if row is None:
return None
portfolio = self._row_to_portfolio(row)
self._attach_tags(cur, [portfolio])
return portfolio
def get_or_create(
self,
portfolio_id: str,
@@ -850,6 +864,7 @@ class PostgresPortfolioRepository:
"asset_price": "asset_price",
"active_strategy_id": "active_strategy_id",
"avabile_strategies": "avabile_strategies",
"managed_by_daemon_id": "managed_by_daemon_id",
}
assignments: list[str] = []
params: list[object] = []