tercul-backend/internal/models/metadata.go
Damir Mukimov fa336cacf3
wip
2025-09-01 00:43:59 +02:00

51 lines
1.4 KiB
Go

package models
import (
"time"
)
// LanguageAnalysis represents language analysis for a work
type LanguageAnalysis struct {
BaseModel
Language string `gorm:"size:50;not null;uniqueIndex:uniq_work_language_analysis"`
Analysis JSONB `gorm:"type:jsonb;default:'{}'"`
WorkID uint `gorm:"index;uniqueIndex:uniq_work_language_analysis"`
Work *Work `gorm:"foreignKey:WorkID"`
}
// Gamification represents gamification elements for a user
type Gamification struct {
BaseModel
Points int `gorm:"default:0"`
Level int `gorm:"default:1"`
Badges JSONB `gorm:"type:jsonb;default:'{}'"`
Streaks int `gorm:"default:0"`
LastActive *time.Time
UserID uint `gorm:"uniqueIndex;index"`
User *User `gorm:"foreignKey:UserID"`
}
// Stats represents general statistics
type Stats struct {
BaseModel
Data JSONB `gorm:"type:jsonb;default:'{}'"`
Period string `gorm:"size:50"` // e.g., daily, weekly, monthly, etc.
StartDate time.Time
EndDate time.Time
UserID *uint
User *User `gorm:"foreignKey:UserID"`
WorkID *uint
Work *Work `gorm:"foreignKey:WorkID"`
}
// SearchDocument is a denormalized text representation for indexing
type SearchDocument struct {
BaseModel
EntityType string `gorm:"size:50;index"`
EntityID uint `gorm:"index"`
LanguageCode string `gorm:"size:16;index"`
Title string `gorm:"size:512"`
Body string `gorm:"type:text"`
Keywords string `gorm:"type:text"`
}