fix: add background task to onboarding order sync + migrate to GitLab

Onboarding fixes:
- Add missing background task trigger for order sync (step 4)
- Import process_historical_import task in onboarding API

GitLab migration:
- Update audit rules to support both GitHub and GitLab paths
- Add .gitlab-ci.yml with lint, test, security, build stages
- Add merge request template (.gitlab/merge_request_templates/default.md)
- Update validate_audit.py to check for GitLab equivalents

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-28 11:52:24 +01:00
parent 11ebb2116a
commit 56bd302361
8 changed files with 208 additions and 14 deletions

View File

@@ -13,12 +13,13 @@ Vendor Context: Uses token_vendor_id from JWT token (authenticated vendor API pa
import logging
from fastapi import APIRouter, Depends
from fastapi import APIRouter, BackgroundTasks, Depends
from sqlalchemy.orm import Session
from app.api.deps import get_current_vendor_api
from app.core.database import get_db
from app.services.onboarding_service import OnboardingService
from app.tasks.letzshop_tasks import process_historical_import
from models.database.user import User
from models.schema.onboarding import (
CompanyProfileRequest,
@@ -206,6 +207,7 @@ def save_product_import_config(
@router.post("/step/order-sync/trigger", response_model=OrderSyncTriggerResponse)
def trigger_order_sync(
request: OrderSyncTriggerRequest,
background_tasks: BackgroundTasks,
current_user: User = Depends(get_current_vendor_api),
db: Session = Depends(get_db),
):
@@ -222,6 +224,16 @@ def trigger_order_sync(
include_products=request.include_products,
)
db.commit() # Commit at API level for transaction control
# Queue background task to process the import
if result.get("success") and result.get("job_id"):
background_tasks.add_task(
process_historical_import,
result["job_id"],
current_user.token_vendor_id,
)
logger.info(f"Queued historical import task for job {result['job_id']}")
return result