# PPR-Only Multiple Tracking IDs - Implementation Complete ## ✅ Changes Implemented Multiple tracking IDs feature is now **ACTIVE in PPR** and **DISABLED in PROD** via environment detection. --- ## Files Modified ### 1. `scripts/shared/filename_parser.py` - Added `__init__` method with DAM URL parameter - Added `_is_ppr_environment()` method - Updated tracking ID parsing to: - **PPR**: Parse multiple IDs separated by `+` (e.g., `BqB8vo+SfUQ7m+laRJo0`) - **PROD**: Use only first ID (backward compatible) ### 2. `scripts/a2_to_a3_upload_polling.py` - Pass DAM URL to FilenameParser for environment detection - Loop through all tracking IDs (PPR) or single ID (PROD) - Look up all master assets in database - Collect all `opentext_id` values - Pass list to metadata extractor ### 3. `scripts/shared/metadata_extractor_mvp.py` - Added `master_opentext_ids` parameter (list) - New method: `_add_master_asset_ids_field()` to handle multiple IDs - Builds `values` array with all master IDs --- ## Environment Detection Logic **PPR Environment:** - DAM URL contains: `ppr.dam.ferrero.com` - Multiple tracking IDs: ✅ **ENABLED** - Filename format: `1234568_ROC_ST_SND_6S_16x9_REF_DE_de_BqB8vo+SfUQ7m.jpg` **PROD Environment:** - DAM URL contains: `dam.ferrero.com` (not ppr) - Multiple tracking IDs: ❌ **DISABLED** - Filename format: `1234568_ROC_ST_SND_6S_16x9_REF_DE_de_BqB8vo.jpg` (single ID) - If multiple IDs provided, uses FIRST ID only with warning --- ## Testing in PPR ### Test 1: Single Tracking ID (Backward Compatible) **Filename:** ``` 1234568_ROC_STRANGER-THINGS_SND_6S_16x9_REF_DE_de_BqB8vo.jpg ``` **Expected Result:** - Parses as single tracking ID - One master asset looked up - One value in MASTERASSETIDS field - ✅ Works exactly as before ### Test 2: Multiple Tracking IDs (New Feature) **Filename:** ``` 1234568_ROC_STRANGER-THINGS_SND_6S_16x9_REF_DE_de_BqB8vo+SfUQ7m+laRJo0.jpg ``` **Expected Result:** - PPR environment detected - Parses 3 tracking IDs: `BqB8vo`, `SfUQ7m`, `laRJo0` - Looks up 3 master assets in database - Gets 3 opentext_ids: - `fc5c389776516bb58044c7d4bf479da458599baf` - `ad3948d72ea8550a338a600ae87a1bdd1968b066` - `020d76f957ec9f4ec0b18035a2d012cd3fd376c2` - Creates MASTERASSETIDS field with 3 values **Log Output:** ``` PPR Environment - Multiple tracking IDs detected: 3 Parsed 3 tracking IDs: BqB8vo, SfUQ7m, laRJo0 PPR - Multiple master assets detected: BqB8vo, SfUQ7m, laRJo0 Using primary master BqB8vo for metadata, linking 3 total masters PPR - Added MASTERASSETIDS field with 3 master IDs Added FERRERO.MASTERASSETIDS field with 3 master asset ID(s): fc5c389776516bb58044c7d4bf479da458599baf, ad3948d72ea8550a338a600ae87a1bdd1968b066, 020d76f957ec9f4ec0b18035a2d012cd3fd376c2 ``` --- ## Test Commands ### Dry Run (Recommended First) ```bash python scripts/a2_to_a3_upload_polling.py --dryrun ``` Check the JSON output for: ```json { "id": "FERRERO.MASTERASSETIDS", "parent_table_id": "FERRERO.TABULAR.FIELD.MASTERASSETIDS", "type": "com.artesia.metadata.MetadataTableField", "values": [ {"value": {"field_value": {"value": "fc5c389776516bb58044c7d4bf479da458599baf"}}}, {"value": {"field_value": {"value": "ad3948d72ea8550a338a600ae87a1bdd1968b066"}}}, {"value": {"field_value": {"value": "020d76f957ec9f4ec0b18035a2d012cd3fd376c2"}}} ] } ``` ### Real Upload to PPR ```bash python scripts/a2_to_a3_upload_polling.py ``` Then verify in PPR DAM: 1. Search for the uploaded asset 2. Open metadata 3. Check "Master Asset IDs" tabular field 4. Should show multiple rows --- ## Error Handling **Missing Master Assets:** - If one tracking ID is not found in database, it's skipped with warning - Derivative still uploads with available master links - Log message: `Master asset not found for tracking ID: xyz - skipping` **PROD Environment with Multiple IDs:** - Uses FIRST tracking ID only - Logs warning: `PROD Environment - Multiple tracking IDs not supported, using first ID only` - Works as backward compatible (no errors) --- ## Current Environment Check Your `.env` file shows: ``` DAM_BASE_URL=https://ppr.dam.ferrero.com/otmmapi ``` ✅ **PPR Environment** - Multiple tracking IDs are **ENABLED** --- ## Agency Tool Requirements To use multiple tracking IDs, the Agency tool needs to: 1. Concatenate tracking IDs with `+` delimiter 2. Example: `tracking_id_1 + "+" + tracking_id_2 + "+" + tracking_id_3` 3. Place in filename: `{job}_{brand}_{...}_{tracking_ids}.{ext}` **Most derivatives will still use single tracking ID** - this is only for special cases where one derivative references multiple masters. --- ## Production Safety ✅ **PROD is Protected:** - Environment detection prevents multiple IDs in PROD - If multiple IDs accidentally used, only first ID is processed - No breaking changes to PROD behavior - Fully backward compatible --- ## Ready to Test! 🚀 Your PPR environment is now ready to test multiple tracking IDs. 1. Create test file with multiple IDs 2. Upload to Box: `DAM-UPLOAD/1234568/` 3. Run with `--dryrun` first 4. Verify JSON shows multiple values 5. Real upload and check in PPR DAM