feat: mailbox-centric activity view, reduce log noise from empty polling cycles
Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/1a78a249-127f-4a73-a454-3c6bafbf6e58 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -61,12 +61,18 @@ async def list_processing_runs(
|
||||
alias="status",
|
||||
description="Filter by run status (completed, failed, partial_failure, running)",
|
||||
),
|
||||
has_emails: Optional[bool] = Query(
|
||||
None,
|
||||
description="When true, only return runs that fetched at least one email",
|
||||
),
|
||||
current_user: User = Depends(get_current_active_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
Return a paginated list of processing runs for all mail accounts owned by
|
||||
the authenticated user, optionally filtered by account or status.
|
||||
the authenticated user, optionally filtered by account, status, or whether
|
||||
any emails were fetched (has_emails=true reduces log noise by hiding empty
|
||||
polling cycles).
|
||||
"""
|
||||
# Base query: join with MailAccount to enforce ownership
|
||||
base = (
|
||||
@@ -79,6 +85,8 @@ async def list_processing_runs(
|
||||
base = base.where(ProcessingRun.mail_account_id == account_id)
|
||||
if status_filter:
|
||||
base = base.where(ProcessingRun.status == status_filter)
|
||||
if has_emails is True:
|
||||
base = base.where(ProcessingRun.emails_fetched > 0)
|
||||
|
||||
# Total count
|
||||
count_q = select(func.count()).select_from(base.subquery())
|
||||
|
||||
@@ -297,6 +297,10 @@ async def list_account_runs(
|
||||
account_id: int,
|
||||
page: int = Query(1, ge=1),
|
||||
page_size: int = Query(20, ge=1, le=100),
|
||||
has_emails: Optional[bool] = Query(
|
||||
None,
|
||||
description="When true, only return runs that fetched at least one email",
|
||||
),
|
||||
current_user: User = Depends(get_current_active_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
@@ -314,6 +318,8 @@ async def list_account_runs(
|
||||
)
|
||||
|
||||
base = select(ProcessingRun).where(ProcessingRun.mail_account_id == account_id)
|
||||
if has_emails is True:
|
||||
base = base.where(ProcessingRun.emails_fetched > 0)
|
||||
total = (
|
||||
await db.execute(select(func.count()).select_from(base.subquery()))
|
||||
).scalar_one()
|
||||
|
||||
Reference in New Issue
Block a user