package de.tsschulz.tt_tagebuch.shared.api.models

import kotlinx.serialization.Serializable

@Serializable
data class TrainingStats(
    val members: List<TrainingStatsMember> = emptyList(),
    val trainingsCount12Months: Int = 0,
    val trainingsCount3Months: Int = 0,
    val trainingDays: List<TrainingStatsDay> = emptyList(),
    val overview: TrainingStatsOverview = TrainingStatsOverview(),
    val weekdayStats: List<TrainingStatsWeekdayBucket> = emptyList(),
    val monthlyTrend: List<TrainingStatsMonthlyTrend> = emptyList(),
    val memberDistribution: TrainingStatsMemberDistribution = TrainingStatsMemberDistribution(),
)

@Serializable
data class TrainingStatsOverview(
    val activeMembersCount: Int = 0,
    val totalParticipants12Months: Int = 0,
    val averageParticipants12Months: Double = 0.0,
    val attendanceRate12Months: Double = 0.0,
    val inactiveMembersCount: Int = 0,
    val bestTrainingDay: TrainingStatsDay? = null,
)

@Serializable
data class TrainingStatsMemberDistribution(
    val highlyActive: Int = 0,
    val regular: Int = 0,
    val occasional: Int = 0,
    val inactive: Int = 0,
)

@Serializable
data class TrainingStatsWeekdayBucket(
    val weekday: String = "",
    val weekdayIndex: Int = 0,
    val trainingCount: Int = 0,
    val participantCount: Int = 0,
    val averageParticipants: Double = 0.0,
)

@Serializable
data class TrainingStatsMonthlyTrend(
    val key: String = "",
    val label: String = "",
    val trainingCount: Int = 0,
    val participantCount: Int = 0,
    val averageParticipants: Double = 0.0,
)

@Serializable
data class TrainingStatsTrainingGroup(
    val id: Int = 0,
    val name: String = "",
)

@Serializable
data class TrainingStatsTrainingDetail(
    val id: Int = 0,
    val date: String? = null,
    val activityName: String? = null,
    val startTime: String? = null,
    val endTime: String? = null,
)

@Serializable
data class TrainingStatsMember(
    val id: Int,
    val firstName: String = "",
    val lastName: String = "",
    val birthDate: String? = null,
    val ttr: Int? = null,
    val qttr: Int? = null,
    val participation12Months: Int = 0,
    val participation3Months: Int = 0,
    val participationTotal: Int = 0,
    val participationRate12Months: Double = 0.0,
    val lastTraining: String? = null,
    val lastTrainingTs: Long = 0,
    val missedTrainingWeeks: Int = 0,
    val notInTraining: Boolean = false,
    val trainingGroups: List<TrainingStatsTrainingGroup> = emptyList(),
    val trainingDetails: List<TrainingStatsTrainingDetail> = emptyList(),
)

@Serializable
data class TrainingStatsDay(
    val id: Int,
    val date: String,
    val participantCount: Int = 0,
    val participants: List<TrainingStatsParticipant> = emptyList(),
)

@Serializable
data class TrainingStatsParticipant(
    val id: Int,
    val firstName: String = "",
    val lastName: String = "",
)
