syntax = "proto3";

package stats;

option go_package = "github.com/echofi-ai/schema/v2/types/stats";

// TrackStatistics message represents aggregated statistics for a track
message TrackStatistics {
  // Track ID
  int32 track_id = 1;

  // Total number of plays
  int64 total_plays = 2;

  // Number of unique listeners
  int64 unique_listeners = 3;

  // Total listening time in seconds
  int64 total_listening_seconds = 4;

  // Average listening duration per play in seconds
  double average_listening_duration = 5;

  // Total favorites
  int64 total_favorites = 6;

  // Total playlist adds
  int64 total_playlist_adds = 7;

  // Completion rate (0-100)
  double completion_rate = 8;

  // Skip rate (0-100)
  double skip_rate = 9;

  // Last updated timestamp (Unix seconds)
  int64 updated_at = 10;

  // Created timestamp (Unix seconds)
  int64 created_at = 11;
}

// ArtistStatistics message represents aggregated statistics for an artist
message ArtistStatistics {
  // Artist ID
  int32 artist_id = 1;

  // Total plays across all tracks
  int64 total_plays = 2;

  // Number of unique listeners across all tracks
  int64 unique_listeners = 3;

  // Total listening time across all tracks in seconds
  int64 total_listening_seconds = 4;

  // Number of followers
  int64 followers_count = 5;

  // Total number of tracks
  int32 total_tracks = 6;

  // Total favorites across all tracks
  int64 total_favorites = 7;

  // Total playlist adds across all tracks
  int64 total_playlist_adds = 8;

  // Average completion rate across all tracks
  double average_completion_rate = 9;

  // Last updated timestamp (Unix seconds)
  int64 updated_at = 10;

  // Created timestamp (Unix seconds)
  int64 created_at = 11;
}

// TimeBasedStats message represents statistics for a specific time period
message TimeBasedStats {
  // Track ID
  int32 track_id = 1;
  
  // Date for the statistics (YYYY-MM-DD format)
  string date = 2;
  
  // Period type (daily, weekly, monthly, yearly)
  string period_type = 3;
  
  // Number of plays in this period
  int64 plays = 4;
  
  // Number of unique listeners in this period
  int64 unique_listeners = 5;
  
  // Total listening time in this period (seconds)
  int64 listening_seconds = 6;
  
  // Number of favorites in this period
  int64 favorites = 7;
  
  // Number of playlist adds in this period
  int64 playlist_adds = 8;
  
  // Trending score for this period
  double trending_score = 9;
  
  // Created timestamp (Unix seconds)
  int64 created_at = 10;
}

// TrendingTrack message represents a track in trending lists
message TrendingTrack {
  // Track ID
  int32 track_id = 1;
  
  // Period type (daily, weekly, monthly, yearly)
  string period_type = 2;
  
  // Ranking position in trending list
  int32 rank = 3;
  
  // Trending score
  double trending_score = 4;
  
  // Change in ranking from previous period (+/- positions)
  int32 rank_change = 5;
  
  // Percentage change in plays from previous period
  double plays_change_percent = 6;
  
  // Date for the trending period
  string period_date = 7;
  
  // Last updated timestamp (Unix seconds)
  int64 updated_at = 8;

  // Created timestamp (Unix seconds)
  int64 created_at = 9;
}

// Note: Request/Response messages (TrendingRequest, TrendingResponse, TrackStatsRequest,
// TrackStatsResponse, ArtistStatsRequest, ArtistStatsResponse) have been moved to service.proto
