Commit graph

15 commits

Author SHA1 Message Date
DJP
2bcac0a08f Add full_metadata JSONB column - Store complete DAM metadata without truncation
Database Changes:
- ALTER TABLE master_assets ADD COLUMN full_metadata JSONB
- Stores COMPLETE DAM asset metadata (no 5,000 char truncation)
- PostgreSQL JSONB type for efficient storage and querying

DatabaseClient Changes:
- Added full_metadata to INSERT and ON CONFLICT UPDATE
- Store complete json_encode($assetData) in full_metadata column
- Simplified description to just Box info (no metadata)
- Log metadata size when storing
- NO TRUNCATION - preserves all fields

Workflow Changes (workflow_v3.php):
- load_master_metadata: Read from full_metadata JSONB column
- upload_from_box: Read from full_metadata JSONB column
- Both endpoints now get COMPLETE master metadata
- Added logging for metadata size verification

Impact:
BEFORE: Only 5,000 chars stored (truncated)
AFTER: Full metadata stored (10,000+ chars, all fields preserved)

Next Step:
Re-download master assets to populate full_metadata for existing records.
New downloads will automatically use the new column.

🤖 Generated with Claude Code
2025-10-29 16:53:51 -04:00
DJP
4e3f47206d Add getConnection() method to DatabaseClient
DatabaseClient now exposes the PDO connection via getConnection().
This allows the upload_from_box AJAX endpoint to query the database.

🤖 Generated with Claude Code
2025-10-29 16:20:43 -04:00
DJP
53b724d5fd Add detailed logging inside getFieldValue to debug NULL returns
Will show:
- What value structure is found
- Which path is used (domain vs regular)
- Why fields return NULL

This will reveal the actual value structure for SUB BRAND, MAIN LANGUAGES, etc.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:42:11 -04:00
DJP
4665e58b03 Clean up metadata extraction - focus on asset-level fields
Removed:
- CAMPAIGN_BRAND lookup (doesn't exist in assets)
- CAMPAIGN_MARKET lookup (doesn't exist in assets)

Improved:
- SUB BRAND extraction
- MAIN LANGUAGES tabular field handling
- MKTG.ASSET TYPE extraction

These fields actually exist in the asset metadata.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:34:53 -04:00
DJP
fd3ed388e7 Extract metadata from ASSET fields (not campaign fields)
Fixed metadata extraction to use fields that exist in assets:
- SUB BRAND → brand_name, brand_code
- MAIN LANGUAGES → language_code
- MKTG.ASSET TYPE → asset_type
- master_content_info → width_px, height_px

Campaign-level fields (CAMPAIGN_BRAND, CAMPAIGN_MARKET) don't exist
on individual assets - they're on the campaign folder.

Using asset-level fields that are actually present.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:34:29 -04:00
DJP
27b5121512 Add detailed field logging to debug metadata extraction
Log every metadata field encountered to see:
- Which fields are in the metadata
- Why CAMPAIGN_BRAND and CAMPAIGN_MARKET aren't being found
- Structure of metadata categories

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:28:22 -04:00
DJP
b2d10b03aa Add more debug logging to trace upload folder and metadata structure 2025-10-29 14:26:57 -04:00
DJP
cccb4b20f2 Add comprehensive debug logging for metadata extraction
Debug what's being passed:
- AssetData keys available
- Upload folder ID value
- Master assets count and structure
- Asset metadata keys per file

This will show exactly what data is available for extraction.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:18:44 -04:00
DJP
105632316f Add debug logging for metadata extraction
Logging to troubleshoot why fields aren't being populated:
- Log extracted metadata values
- Log upload folder ID
- Log width/height extraction
- Check asset_content_info structure variations

Will show in logs what's being extracted vs what's NULL.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:14:18 -04:00
DJP
afe79bbbcc Extract and populate all database fields from DAM metadata
DatabaseClient now extracts and stores:
- brand_code, brand_name (from FERRERO.FIELD.CAMPAIGN_BRAND)
- country_code (from FERRERO.FIELD.CAMPAIGN_MARKET)
- language_code (to be extracted from filename or metadata)
- asset_type (from metadata fields)
- width_px, height_px (from asset_content_info.master_content)
- file_size_bytes (from asset data)
- mime_type (from asset data)
- upload_directory (Final Assets folder ID passed from workflow)

Handles both domain values and regular values.
Populates all available database columns from DAM metadata.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:06:14 -04:00
DJP
2b42b4e42e Store DAM metadata JSON in database description field + test Box template
Database:
- Store full DAM metadata JSON in description field (5KB limit)
- Includes Box links and upload folder ID
- Full asset metadata preserved

Box Metadata Template Testing:
- Simplified to send just test string first
- Log endpoint and values being sent
- Try 5 field name variations
- Will identify correct field name from logs

Next test will show which field name works for Box template.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 17:09:58 -04:00
DJP
f002d734a7 Store upload folder ID in upload_directory column
Database now stores:
- upload_directory = Final Assets folder ID from DAM
- This is the target folder for A2→A3 uploads
- Can be retrieved later when uploading processed files back to DAM

Column exists in DB, now being populated correctly.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 17:05:44 -04:00
DJP
c3d3878b3a Add Final Assets folder ID extraction and storage in database
Workflow Enhancement:
- When getting Master Assets, also find Final Assets folder
- Store Final Assets folder ID in session for later upload use
- Pass upload folder ID to database storage

Database Storage:
- Store upload folder ID in description field
- Ready for dedicated upload_directory column when added to DB schema

UI Update:
- Success message shows Final Assets folder was located

This ensures we have the upload target folder ID when needed for A2→A3 workflow.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 17:05:11 -04:00
DJP
576dd72081 Fix Box metadata template name and database columns
Box Metadata Template:
- Fixed template key: 'ferrerodammetadata' (lowercase)
- Fixed field name: 'DAM-Metadata' (exact from template)
- Should now properly attach metadata to Box files

Database Fix:
- Removed non-existent columns: box_file_id, box_url, dam_metadata_json
- Using only existing columns from master_assets table
- Storing Box URL in description field as workaround
- Will add proper columns in DB migration later

Next: Box metadata template should work, DB inserts should succeed.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 16:23:38 -04:00
DJP
d8e542a569 Add PostgreSQL database integration and Box metadata template
Database Integration:
- IDGenerator now connects to PostgreSQL (localhost:5433)
- Generates tracking IDs with uniqueness check against master_assets table
- Fallback to random if database unavailable
- Direct PDO connection to ferrero_tracking database

DatabaseClient:
- Stores master assets in PostgreSQL
- Records: tracking_id, opentext_id, Box links, full metadata JSON
- Updates on conflict (upsert pattern)
- Stores box_file_id and box_url for reference

Box Metadata Enhancement:
- Uses Box metadata template API (enterprise/ferreroDAMMetadata)
- Stores full DAM metadata JSON in 'Ferrero-DAM-Metadata' field
- Fallback to file description if template not configured
- Handles template conflicts (updates existing)

Box Upload Results Now Show:
- Unique tracking ID (from database)
- Box file links (clickable)
- Database storage status
- ID source (database_direct, random, etc.)

Complete workflow: DAM → Download → Generate ID → Upload to Box → Store in DB

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 15:39:32 -04:00