# apps/participants/models.py
from django.db import models
from apps.core.models import TimeStampedModel
import re
from django.core.exceptions import ValidationError

class Participant(TimeStampedModel):
    group_name = models.CharField(max_length=80, unique=True)

    # diffs en porcentaje
    R_diff  = models.FloatField()
    L_diff  = models.FloatField()
    Ph_diff = models.FloatField()
    Pcu_diff= models.FloatField()
    s_vol_over_eta = models.FloatField()
    score = models.FloatField(default=0)

    class Meta:
        ordering = ["-score"]

    def __str__(self):
        return self.group_name
    
    def clean(self):
        super().clean()
        if self.s_vol_over_eta <= 0:
            raise ValidationError({"s_vol_over_eta": "Debe ser mayor que 0"})
