feat: add postgres repository for training
This commit is contained in:
parent
8c277ef692
commit
ff7e320481
19 changed files with 1277 additions and 414 deletions
|
|
@ -207,11 +207,11 @@ func (f *Faker) GenerateFakeData() error {
|
|||
}
|
||||
|
||||
now := time.Now()
|
||||
min := time.Date(now.Year(), now.Month(), now.Day(), 8, 0, 0, 0, time.UTC)
|
||||
max := time.Date(now.Year()+1, now.Month(), now.Day(), 8, 0, 0, 0, time.UTC)
|
||||
delta := max.Sub(min)
|
||||
minT := time.Date(now.Year(), now.Month(), now.Day(), 8, 0, 0, 0, time.UTC)
|
||||
maxT := time.Date(now.Year()+1, now.Month(), now.Day(), 8, 0, 0, 0, time.UTC)
|
||||
delta := maxT.Sub(minT)
|
||||
|
||||
sec := rand.Int64N(int64(delta.Seconds())) + min.UnixNano()/1000000000
|
||||
sec := rand.Int64N(int64(delta.Seconds())) + minT.UnixNano()/1000000000
|
||||
date := time.Unix(sec, 0)
|
||||
|
||||
amount := decimal.NewFromInt(4900)
|
||||
|
|
@ -231,21 +231,19 @@ func (f *Faker) GenerateFakeData() error {
|
|||
}
|
||||
|
||||
td := training.TrainingDate{
|
||||
Date: date,
|
||||
StartTime: date.Truncate(24 * time.Hour),
|
||||
Days: t.Days,
|
||||
IsOnline: online,
|
||||
Location: location,
|
||||
Address: "TBD",
|
||||
Capacity: 12,
|
||||
Price: money.Price{
|
||||
Amount: amount,
|
||||
Currency: cur,
|
||||
},
|
||||
Date: date,
|
||||
StartTime: date.Truncate(24 * time.Hour),
|
||||
Days: t.Days,
|
||||
IsOnline: online,
|
||||
Location: location,
|
||||
Address: "TBD",
|
||||
Capacity: 12,
|
||||
PriceAmount: amount,
|
||||
PriceCurrency: cur,
|
||||
}
|
||||
err := f.trainingDateRepository.Create(t.ID, &td)
|
||||
if err != nil {
|
||||
return err
|
||||
dateErr := f.trainingDateRepository.Create(t.ID, &td)
|
||||
if dateErr != nil {
|
||||
return dateErr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue