syntax = "proto3";

package stats;

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

import "stats/user_statistics.proto";
import "stats/point_boost.proto";
import "stats/track_statistics.proto";

// StatsService defines the gRPC service for statistics operations
service StatsService {
  // GetUserStatistics retrieves user statistics by user ID
  rpc GetUserStatistics(GetUserStatisticsRequest) returns (GetUserStatisticsResponse) {}

  // ListUserStatistics retrieves user statistics with pagination
  rpc ListUserStatistics(ListUserStatisticsRequest) returns (ListUserStatisticsResponse) {}

  // GetPointBoost retrieves a point boost by ID
  rpc GetPointBoost(GetPointBoostRequest) returns (GetPointBoostResponse) {}

  // ListPointBoosts retrieves point boosts with pagination
  rpc ListPointBoosts(ListPointBoostsRequest) returns (ListPointBoostsResponse) {}

  // GetUserBoostRate retrieves the current active boost rate for the authenticated user
  rpc GetUserBoostRate(GetUserBoostRateRequest) returns (GetUserBoostRateResponse) {}

  // GetTrackStatistics retrieves statistics for a specific track
  rpc GetTrackStatistics(TrackStatsRequest) returns (TrackStatsResponse) {}

  // GetArtistStatistics retrieves statistics for a specific artist
  rpc GetArtistStatistics(ArtistStatsRequest) returns (ArtistStatsResponse) {}

  // GetTrendingTracks retrieves trending tracks for a specific period
  rpc GetTrendingTracks(TrendingRequest) returns (TrendingResponse) {}

  // GetHotTracks retrieves hot tracks (trending in last 24 hours)
  rpc GetHotTracks(TrendingRequest) returns (TrendingResponse) {}

  // GetTopTracks retrieves top tracks for a specific time period
  rpc GetTopTracks(TrendingRequest) returns (TrendingResponse) {}

}

// User Statistics requests and responses
message GetUserStatisticsRequest {
  // No user_id needed - will use authenticated user from context
}

message GetUserStatisticsResponse {
  UserStatistics statistics = 1;
}

message ListUserStatisticsRequest {
  int32 offset = 1;
  int32 limit = 2;
}

message ListUserStatisticsResponse {
  repeated UserStatistics statistics = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Point Boost requests and responses
message GetPointBoostRequest {
  int32 boost_id = 1;
}

message GetPointBoostResponse {
  PointBoost boost = 1;
}

message ListPointBoostsRequest {
  int32 offset = 1;
  int32 limit = 2;
  // user_id removed - will use authenticated user from context
  optional bool is_active = 3; // Filter by active status
}

message ListPointBoostsResponse {
  repeated PointBoost boosts = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// User Boost Rate requests and responses
message GetUserBoostRateRequest {
  // No user_id needed - will use authenticated user from context
}

message GetUserBoostRateResponse {
  PointBoost boost = 1;
}

// Track Statistics requests and responses
message TrackStatsRequest {
  // Track ID
  int32 track_id = 1;

  // Include time-based breakdown
  bool include_time_breakdown = 2;

  // Time period for breakdown (daily, weekly, monthly)
  optional string breakdown_period = 3;

  // Number of periods to include in breakdown
  optional int32 breakdown_limit = 4;
}

message TrackStatsResponse {
  // Track statistics
  TrackStatistics statistics = 1;

  // Time-based breakdown (if requested)
  repeated TimeBasedStats time_breakdown = 2;
}

// Artist Statistics requests and responses
message ArtistStatsRequest {
  // Artist ID
  int32 artist_id = 1;

  // Include top tracks
  bool include_top_tracks = 2;

  // Number of top tracks to include
  optional int32 top_tracks_limit = 3;
}

message ArtistStatsResponse {
  // Artist statistics
  ArtistStatistics statistics = 1;

  // Top tracks (if requested)
  repeated TrackStatistics top_tracks = 2;
}

// Trending requests and responses
message TrendingRequest {
  // Period type (daily, weekly, monthly, yearly)
  string period_type = 1;

  // Optional genre filter
  optional int32 genre_id = 2;

  // Number of results to return (default: 50)
  int32 limit = 3;

  // Offset for pagination
  int32 offset = 4;

  // Optional date for historical trending (YYYY-MM-DD format)
  optional string date = 5;
}

message TrendingResponse {
  // List of trending tracks
  repeated TrendingTrack tracks = 1;

  // Total count of trending tracks
  int64 total_count = 2;

  // Period information
  string period_type = 3;

  // Date for the trending period
  string period_date = 4;
}
