42 lines
666 B
Go
42 lines
666 B
Go
package machine
|
|
|
|
import (
|
|
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/fsm/machine/dto"
|
|
"time"
|
|
|
|
"github.com/maypok86/otter"
|
|
)
|
|
|
|
type MemberVote struct {
|
|
dto.Member
|
|
Vote float32
|
|
}
|
|
|
|
type PollResult struct {
|
|
Max float32
|
|
Min float32
|
|
Avg float32
|
|
Halved float32
|
|
}
|
|
|
|
type PollState struct {
|
|
Members []dto.Member
|
|
Votes []MemberVote
|
|
Result PollResult
|
|
}
|
|
|
|
var Polls otter.Cache[uint64, PollState]
|
|
|
|
func init() {
|
|
cache, err := otter.MustBuilder[uint64, PollState](10_000).
|
|
Cost(func(key uint64, value PollState) uint32 {
|
|
return 1
|
|
}).
|
|
WithTTL(time.Hour * 24 * 7).
|
|
Build()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
Polls = cache
|
|
}
|