jobs: extract shared market-context helpers from ai_log_job
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ce4b19dbb8
commit
82e529b6b2
3 changed files with 104 additions and 84 deletions
|
|
@ -20,11 +20,11 @@ from app import branding
|
|||
from app.config import get_settings
|
||||
from app.db import utcnow
|
||||
from app.jobs._helpers import job_lifecycle, log
|
||||
from app.jobs.ai_log_job import (
|
||||
from app.jobs._market_context import (
|
||||
REFERENCE_LINE,
|
||||
_latest_quotes_by_group,
|
||||
_recent_headlines_by_bucket,
|
||||
_month_spend,
|
||||
latest_quotes_by_group,
|
||||
month_spend,
|
||||
recent_headlines_by_bucket,
|
||||
)
|
||||
from app.models import EmailSend, User
|
||||
from app.routers.email import sign_unsubscribe_token
|
||||
|
|
@ -172,7 +172,7 @@ async def run() -> None:
|
|||
jr.status = "skipped"
|
||||
return
|
||||
|
||||
spent = await _month_spend(session)
|
||||
spent = await month_spend(session)
|
||||
if spent >= s.OPENROUTER_MONTHLY_CAP_USD:
|
||||
log.warning("digest.cap_reached", spent=spent,
|
||||
cap=s.OPENROUTER_MONTHLY_CAP_USD)
|
||||
|
|
@ -180,8 +180,8 @@ async def run() -> None:
|
|||
jr.error = f"monthly cost cap reached (${spent:.2f})"
|
||||
return
|
||||
|
||||
quotes = await _latest_quotes_by_group(session)
|
||||
news = await _recent_headlines_by_bucket(
|
||||
quotes = await latest_quotes_by_group(session)
|
||||
news = await recent_headlines_by_bucket(
|
||||
session, hours=(168 if kind == "weekly" else 24),
|
||||
)
|
||||
ctx = dict(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue