fix: add historical import jobs to unified jobs list
Historical import jobs were not appearing in the recent jobs list because list_letzshop_jobs() only queried marketplace_import_jobs and letzshop_sync_logs. Changes: - Add LetzshopHistoricalImportJob query to list_letzshop_jobs() - Add current_phase and error_message fields to LetzshopJobItem schema - Fixed stuck job 8 (marked as failed) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -556,11 +556,42 @@ class LetzshopOrderService:
|
||||
"""
|
||||
List unified Letzshop-related jobs for a vendor.
|
||||
|
||||
Combines product imports from marketplace_import_jobs and
|
||||
order syncs from letzshop_sync_logs.
|
||||
Combines product imports, historical order imports, and order syncs.
|
||||
"""
|
||||
jobs = []
|
||||
|
||||
# Historical order imports from letzshop_historical_import_jobs
|
||||
if job_type in (None, "historical_import"):
|
||||
hist_query = self.db.query(LetzshopHistoricalImportJob).filter(
|
||||
LetzshopHistoricalImportJob.vendor_id == vendor_id,
|
||||
)
|
||||
if status:
|
||||
hist_query = hist_query.filter(
|
||||
LetzshopHistoricalImportJob.status == status
|
||||
)
|
||||
|
||||
hist_jobs = hist_query.order_by(
|
||||
LetzshopHistoricalImportJob.created_at.desc()
|
||||
).all()
|
||||
|
||||
for job in hist_jobs:
|
||||
jobs.append(
|
||||
{
|
||||
"id": job.id,
|
||||
"type": "historical_import",
|
||||
"status": job.status,
|
||||
"created_at": job.created_at,
|
||||
"started_at": job.started_at,
|
||||
"completed_at": job.completed_at,
|
||||
"records_processed": job.orders_processed or 0,
|
||||
"records_succeeded": (job.orders_imported or 0)
|
||||
+ (job.orders_updated or 0),
|
||||
"records_failed": job.orders_skipped or 0,
|
||||
"current_phase": job.current_phase,
|
||||
"error_message": job.error_message,
|
||||
}
|
||||
)
|
||||
|
||||
# Product imports from marketplace_import_jobs
|
||||
if job_type in (None, "import"):
|
||||
import_query = self.db.query(MarketplaceImportJob).filter(
|
||||
|
||||
Reference in New Issue
Block a user