Statistics Storage and Analysis Module

This module provides comprehensive functionality for storing, retrieving, and analyzing Spotify listening statistics. It serves as the data persistence layer for all metrics related to playback behavior, skip patterns, and listening habits.

Features:

  • Persistent storage of all listening statistics and metrics
  • Data normalization and integrity preservation
  • Comprehensive pattern analysis algorithms
  • Time-based aggregation (daily, weekly, monthly)
  • Artist and track-level metrics
  • Device usage analytics
  • Skip pattern detection and classification
  • Context-aware listening analysis
  • Temporal behavior modeling (time of day, day of week)
  • Session tracking and analysis
  • Data import/export capabilities

The module ensures proper data serialization/deserialization, handling specialized data structures like Sets appropriately for storage. It includes validation and repair mechanisms to maintain data integrity across application restarts.

This serves as the foundation for all data visualization and insights presented in the application's statistics dashboard.

Functions

getStatistics
saveStatistics
calculateUniqueArtistCount
updateTrackStatistics
clearStatistics
analyzeManualVsAutoSkipPatterns
analyzeListeningContextPatterns
analyzeTimeOfDaySkipPatterns
getStatisticsSummary
getRecentSkippedTracks
getTopSkippedArtists
getRecentSessions
exportStatistics
clearAllStatistics