app

package
v0.0.0-...-53d67a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func IndexOf

func IndexOf[T comparable](slice []T, element T) int

func InitDB

func InitDB()

func InsertSampleData

func InsertSampleData()

Types

type Account

type Account struct {
	ID        uint      `json:"id"`
	CreatedAt time.Time `json:"created_at" gorm:"<-:create"`
	UpdatedAt time.Time `json:"updated_at"`

	Name string `json:"name" gorm:"not null"`
}

type Bookmaker

type Bookmaker struct {
	ID        uint      `json:"id"`
	CreatedAt time.Time `json:"created_at" gorm:"<-:create"`
	UpdatedAt time.Time `json:"updated_at"`

	Name              string `json:"name" gorm:"not null" `
	DefaultCommission uint   `json:"default_commission" gorm:"not null"`
}

func (Bookmaker) IsExchange

func (b Bookmaker) IsExchange() bool

type Entry

type Entry struct {
	ID        uint      `json:"id"`
	CreatedAt time.Time `json:"created_at" gorm:"<-:create"`
	UpdatedAt time.Time `json:"updated_at"`

	RecordID    uint `json:"record_id" gorm:"not null"`
	BookmakerID uint `json:"bookmaker_id" gorm:"not null"`
	AccountID   uint `json:"account_id" gorm:"not null"`
	Amount      uint `json:"amount" gorm:"not null"`     // In cents (ex: 100 = 1.00)
	Refund      uint `json:"refund" gorm:"not null"`     // In cents (ex: 100 = 1.00)
	Bonus       uint `json:"bonus" gorm:"not null"`      // In cents (ex: 50 = 0.50)
	Commission  uint `json:"commission" gorm:"not null"` // In cents (ex: 4.5% = 450)

	Odds  *uint      `json:"odds" gorm:"-"`
	Won   *bool      `json:"won" gorm:"-"`
	Date  *time.Time `json:"date" gorm:"-"`
	Value *int       `json:"value" gorm:"-"`

	Bookmaker  Bookmaker  `json:"bookmaker" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Account    Account    `json:"account" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	SubEntries []SubEntry `json:"sub_entries" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func FillEntryValues

func FillEntryValues(entries []Entry) ([]Entry, int)

func (*Entry) DidWin

func (e *Entry) DidWin() *bool

func (*Entry) GetDate

func (e *Entry) GetDate() *time.Time

func (*Entry) GetOdds

func (e *Entry) GetOdds() *uint

func (*Entry) GetValue

func (e *Entry) GetValue() (value int)

type Record

type Record struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at" gorm:"<-:create"`
	UpdatedAt time.Time `json:"updated_at"`

	Done        bool   `json:"done" gorm:"not null"`
	Type        string `json:"type" gorm:"not null"`
	Description string `json:"description" gorm:"not null"`

	Date  *time.Time `json:"date" gorm:"-"`
	Value *int       `json:"value" gorm:"-"`

	Entries []Entry `json:"entries" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func FillRecordValues

func FillRecordValues(records []Record) ([]Record, int)

func GetRecord

func GetRecord(id uint) (record Record, err error)

func GetRecords

func GetRecords() (records []Record, total int, err error)

func (*Record) GetDate

func (r *Record) GetDate() *time.Time

type SubEntry

type SubEntry struct {
	ID        uint      `json:"id"`
	CreatedAt time.Time `json:"created_at" gorm:"<-:create"`
	UpdatedAt time.Time `json:"updated_at"`

	EntryID     uint      `json:"entry_id" gorm:"not null"`
	Description string    `json:"description" gorm:"not null"`
	Odds        uint      `json:"odds" gorm:"not null"` // In cents (ex: 200 = 2.00)
	Won         bool      `json:"won" gorm:"not null"`
	Date        time.Time `json:"date" gorm:"not null;default:current_timestamp"`

	Value *int `json:"value" gorm:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL