f29471cb5d
* backup current work * Add AI functionality * update docker-compose.yml * update docker-compose.yaml file --------- Co-authored-by: Erikas <erkexzcx@users.noreply.github.com>
33 lines
684 B
Go
33 lines
684 B
Go
package flightlesssomething
|
|
|
|
import (
|
|
"github.com/dustin/go-humanize"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type User struct {
|
|
gorm.Model
|
|
DiscordID string
|
|
Username string
|
|
|
|
Benchmarks []Benchmark `gorm:"constraint:OnDelete:CASCADE;"`
|
|
}
|
|
|
|
type Benchmark struct {
|
|
gorm.Model
|
|
UserID uint
|
|
Title string
|
|
Description string
|
|
AiSummary string
|
|
|
|
CreatedAtHumanized string `gorm:"-"` // Human readable "X h/m/s ago" version of CreatedAt (filled automatically)
|
|
|
|
User User `gorm:"foreignKey:UserID;"`
|
|
}
|
|
|
|
// AfterFind is a GORM hook that is called after a record is found
|
|
func (b *Benchmark) AfterFind(tx *gorm.DB) (err error) {
|
|
b.CreatedAtHumanized = humanize.Time(b.CreatedAt)
|
|
return nil
|
|
}
|