RangoDisco / zelvy

Tracking my fitness related goals
2 stars 0 forks source link

Feat: pick winner between users instead of .env ids #9

Closed RangoDisco closed 2 months ago

RangoDisco commented 2 months ago

Pick the winner by fetching in the database instead of the list of ids in the .env file.

Also would be fun to log each time a user is picked, whether they won money or not and the date

Prolly deserves a table on its own in order to log the date and if they won money

RangoDisco commented 2 months ago

created new table Win:

package models

import (
    "github.com/google/uuid"
    "gorm.io/gorm"
    "time"
)

type Win struct {
    ID           uuid.UUID `gorm:"type:uuid;primaryKey"`
    ShouldBePaid bool      `gorm:"default:false"`
    UserID       uuid.UUID `json:"userId"`
    CreatedAt    time.Time `gorm:"CreateTime"`
}

func (w *Win) BeforeCreate(_ *gorm.DB) (err error) {
    w.ID = uuid.New()
    return
}