ferrero-opentext/Python-Version/scripts/shared
DJP 766063079c Remove slow job polling, add fast folder search for asset IDs
Replaces 20+ second job polling with instant folder search.

PERFORMANCE IMPROVEMENT:
Before: Poll job 10 times, 2 sec each = 20+ seconds per upload
After: No polling, instant return + optional folder search

CHANGES:
1. Removed job polling from upload_asset()
   - No more 20 second waits
   - Returns job_id immediately for async uploads
   - Adds 'is_async' flag to response

2. NEW METHOD: find_asset_by_filename_in_folder()
   - Fast search by filename in folder
   - Can be called after batch uploads complete
   - Returns actual asset ID instantly

UPLOAD FLOW:
Immediate Response (201):
  → Returns asset ID immediately
  → Log: "Upload successful (immediate): file.jpg → Asset ID: abc123"

Async Response (202):
  → Returns job ID immediately (no waiting!)
  → Log: "Upload accepted (async): file.jpg → Job ID: job456"
  → Log: "Note: Job processing in background. Asset ID can be found later."

FINDING ASSET ID LATER (OPTIONAL):
After batch uploads, call once per folder:
```python
# Upload all files first (fast!)
for file in files:
    result = dam.upload_asset(...)
    job_ids.append(result['job_id'])

# Then search folder for actual IDs (one API call)
for filename in filenames:
    asset_id = dam.find_asset_by_filename_in_folder(folder_id, filename)
```

BENEFITS:
✓ No 20 second waits per file
✓ Batch uploads can run quickly
✓ Optional post-upload search for asset IDs
✓ Single API call to get all IDs

USE CASES:
- Fast uploads: Don't need immediate asset ID
- Batch processing: Upload many files quickly
- Later retrieval: Search folder when needed
- Status updates: Can update campaign without waiting

The job_id is stored and can be used for tracking.
Actual asset_id can be retrieved later if needed.

Changes:
- scripts/shared/dam_client.py
  - Removed polling from upload_asset()
  - Added find_asset_by_filename_in_folder() method
  - Returns immediately with job_id for async
  - Added 'is_async' flag to response

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 14:12:39 -05:00
..
__pycache__ Update comprehensive README and reorganize documentation files 2025-11-05 10:57:11 -05:00
__init__.py Start Python automation - Foundation components 2025-10-30 16:38:26 -04:00
box_client.py Add recursive folder search, NOT APPROVED filtering, and rejection details for A5→A6 2025-11-04 14:49:19 -05:00
config_loader.py Start Python automation - Foundation components 2025-10-30 16:38:26 -04:00
dam_client.py Remove slow job polling, add fast folder search for asset IDs 2025-11-05 14:12:39 -05:00
database.py Add A5→A6 rework workflow automation (Python) 2025-11-04 13:36:35 -05:00
filename_parser.py Complete Python automation implementation - All components built 2025-10-30 16:49:14 -04:00
metadata_extractor_mvp.py Add Box metadata extraction for CreativeX fields in A2→A3 workflow 2025-11-03 14:26:00 -05:00
notifier.py Add daily summary report with comprehensive statistics 2025-11-04 16:34:44 -05:00