Complete analytics module object interface migration #162

Open
opened 2025-10-14 22:07:21 +00:00 by tegwick · 0 comments
Owner

Problem

Some parts of the analytics module still expect dict-based asset access patterns, creating inconsistencies with the new object-based Asset model.

Evidence

During the dict-to-object migration, several fixes were needed:

  • analytics.py had to be updated to use list_assets_as_objects() instead of list_assets()
  • get_asset() calls needed to be changed to get_asset_as_object()
  • Mixed dict/object access patterns in usage report generation

Remaining Issues

Some analytics code may still have remnants of dict-based assumptions that could cause issues in edge cases.

Impact

  • Type safety not fully enforced in analytics
  • Potential runtime errors if dict access patterns remain
  • Inconsistent developer experience across the system
  • Reduced IDE support and code completion

Proposed Solution

  1. Audit all analytics code for dict vs object access patterns
  2. Add type hints throughout analytics module for Asset objects
  3. Create analytics-specific Asset utilities if needed
  4. Update tests to verify object-based interfaces work correctly

Benefits

  • Full type safety across the system
  • Better IDE support and developer experience
  • Consistent object-based interfaces everywhere
  • Easier maintenance and debugging

Files Affected

  • markitect/assets/analytics.py - Core analytics logic
  • Tests for analytics functionality
  • Any CLI commands that use analytics

Priority

Medium - Improves code quality and prevents future bugs

## Problem Some parts of the analytics module still expect dict-based asset access patterns, creating inconsistencies with the new object-based Asset model. ## Evidence During the dict-to-object migration, several fixes were needed: - analytics.py had to be updated to use list_assets_as_objects() instead of list_assets() - get_asset() calls needed to be changed to get_asset_as_object() - Mixed dict/object access patterns in usage report generation ## Remaining Issues Some analytics code may still have remnants of dict-based assumptions that could cause issues in edge cases. ## Impact - Type safety not fully enforced in analytics - Potential runtime errors if dict access patterns remain - Inconsistent developer experience across the system - Reduced IDE support and code completion ## Proposed Solution 1. **Audit all analytics code** for dict vs object access patterns 2. **Add type hints** throughout analytics module for Asset objects 3. **Create analytics-specific Asset utilities** if needed 4. **Update tests** to verify object-based interfaces work correctly ## Benefits - Full type safety across the system - Better IDE support and developer experience - Consistent object-based interfaces everywhere - Easier maintenance and debugging ## Files Affected - markitect/assets/analytics.py - Core analytics logic - Tests for analytics functionality - Any CLI commands that use analytics ## Priority Medium - Improves code quality and prevents future bugs
tegwick added this to the Images And File Attachments project 2025-10-14 22:21:06 +00:00
Sign in to join this conversation.