Show total pages and card-local AJAX paging on options review.
Trades and reviewed lists now report page X / Y and flip without full-page sync refresh. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -591,8 +591,7 @@ def enrich_trade_row(row: dict[str, Any], entry: dict[str, Any] | None = None) -
|
||||
return out
|
||||
|
||||
|
||||
def list_review_trades(
|
||||
conn: sqlite3.Connection,
|
||||
def _review_trades_filters(
|
||||
*,
|
||||
source_type: str | None = None,
|
||||
underlying: str | None = None,
|
||||
@@ -602,10 +601,7 @@ def list_review_trades(
|
||||
include_hedge_legs: bool = False,
|
||||
closed_from: str | None = None,
|
||||
closed_to: str | None = None,
|
||||
limit: int = 200,
|
||||
offset: int = 0,
|
||||
) -> list[dict[str, Any]]:
|
||||
init_options_review_tables(conn)
|
||||
) -> tuple[str, list[Any]]:
|
||||
wheres: list[str] = []
|
||||
args: list[Any] = []
|
||||
if source_type and source_type in SOURCE_TYPES:
|
||||
@@ -647,6 +643,69 @@ def list_review_trades(
|
||||
elif reviewed == "0" or reviewed == "no":
|
||||
wheres.append("e.id IS NULL")
|
||||
where = (" WHERE " + " AND ".join(wheres)) if wheres else ""
|
||||
return where, args
|
||||
|
||||
|
||||
def count_review_trades(
|
||||
conn: sqlite3.Connection,
|
||||
*,
|
||||
source_type: str | None = None,
|
||||
underlying: str | None = None,
|
||||
opt_type: str | None = None,
|
||||
strategy_tag: str | None = None,
|
||||
reviewed: str | None = None,
|
||||
include_hedge_legs: bool = False,
|
||||
closed_from: str | None = None,
|
||||
closed_to: str | None = None,
|
||||
) -> int:
|
||||
init_options_review_tables(conn)
|
||||
where, args = _review_trades_filters(
|
||||
source_type=source_type,
|
||||
underlying=underlying,
|
||||
opt_type=opt_type,
|
||||
strategy_tag=strategy_tag,
|
||||
reviewed=reviewed,
|
||||
include_hedge_legs=include_hedge_legs,
|
||||
closed_from=closed_from,
|
||||
closed_to=closed_to,
|
||||
)
|
||||
row = conn.execute(
|
||||
f"""
|
||||
SELECT COUNT(*) AS c
|
||||
FROM options_review_trades t
|
||||
LEFT JOIN options_review_entries e ON e.trade_id = t.id
|
||||
{where}
|
||||
""",
|
||||
args,
|
||||
).fetchone()
|
||||
return int(row["c"] if row else 0)
|
||||
|
||||
|
||||
def list_review_trades(
|
||||
conn: sqlite3.Connection,
|
||||
*,
|
||||
source_type: str | None = None,
|
||||
underlying: str | None = None,
|
||||
opt_type: str | None = None,
|
||||
strategy_tag: str | None = None,
|
||||
reviewed: str | None = None,
|
||||
include_hedge_legs: bool = False,
|
||||
closed_from: str | None = None,
|
||||
closed_to: str | None = None,
|
||||
limit: int = 200,
|
||||
offset: int = 0,
|
||||
) -> list[dict[str, Any]]:
|
||||
init_options_review_tables(conn)
|
||||
where, args = _review_trades_filters(
|
||||
source_type=source_type,
|
||||
underlying=underlying,
|
||||
opt_type=opt_type,
|
||||
strategy_tag=strategy_tag,
|
||||
reviewed=reviewed,
|
||||
include_hedge_legs=include_hedge_legs,
|
||||
closed_from=closed_from,
|
||||
closed_to=closed_to,
|
||||
)
|
||||
rows = conn.execute(
|
||||
f"""
|
||||
SELECT t.*, e.id AS entry_id, e.strategy_tag AS e_strategy_tag,
|
||||
|
||||
Reference in New Issue
Block a user