40 lines
920 B
Go
Raw Permalink Normal View History

2025-02-12 21:26:04 +08:00
package models
import (
"time"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
"gorm.io/datatypes"
)
type Poll struct {
cruda.BaseModel
ExpiredAt *time.Time `json:"expired_at"`
Options datatypes.JSONSlice[PollOption] `json:"options"`
AccountID uint `json:"account_id"`
Metric PollMetric `json:"metric" gorm:"-"`
}
type PollMetric struct {
TotalAnswer int64 `json:"total_answer"`
ByOptions map[string]int64 `json:"by_options"`
ByOptionsPercentage map[string]float64 `json:"by_options_percentage"`
2025-02-12 21:26:04 +08:00
}
type PollOption struct {
ID string `json:"id"`
Icon string `json:"icon"`
Name string `json:"name"`
Description string `json:"description"`
}
type PollAnswer struct {
cruda.BaseModel
Answer string `json:"answer"`
PollID uint `json:"poll_id"`
AccountID uint `json:"account_id"`
}