from django.db import models


class VoteSite(models.Model):
    name = models.CharField(max_length=100, unique=True)
    url = models.URLField(max_length=200, help_text="URL del sitio de votación")
    image_url = models.URLField(max_length=300, help_text="URL completa de la imagen")
    points = models.IntegerField(default=1, help_text="Puntos otorgados por votar")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.name

class VoteLog(models.Model):
    account_id = models.IntegerField()
    vote_site = models.ForeignKey('VoteSite', on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    last_vote_time = models.DateTimeField(null=True, blank=True)
    processed = models.BooleanField(default=False)
    processed_at = models.DateTimeField(null=True, blank=True)

    def __str__(self):
        return f"Voto para {self.vote_site.name} por cuenta {self.account_id}"

class HomeApiPoints(models.Model):
    accountID = models.IntegerField(unique=True)
    vp = models.IntegerField(default=0)
    dp = models.IntegerField(default=0)
    
    class Meta:
        db_table = 'home_api_points'

    def __str__(self):
        return f"Cuenta {self.accountID} - PV: {self.vp}, DP: {self.dp}" 
