package models

import (
	"time"

	"github.com/google/uuid"
)

// PostCategoryView tracks visits to post categories.
type PostCategoryView struct {
	ID         uuid.UUID    `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
	CategoryID uuid.UUID    `gorm:"not null;index:idx_post_category_views,priority:1" json:"category_id"`
	Category   PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
	IPAddress  string       `gorm:"type:varchar(64);not null;index:idx_post_category_views,priority:2" json:"ip_address"`
	UserAgent  string       `gorm:"type:text" json:"user_agent,omitempty"`
	CreatedAt  time.Time    `gorm:"index:idx_post_category_views,priority:3" json:"created_at"`
}

// TableName overrides the table name used by PostCategoryView.
func (PostCategoryView) TableName() string {
	return "post_category_views"
}
