zero prices methods
This commit is contained in:
parent
33327eaa2c
commit
756b5c126f
3 changed files with 235 additions and 112 deletions
|
|
@ -14,7 +14,7 @@ type Prices interface {
|
|||
|
||||
getZeroPrices(ctx context.Context, userId int64) ([]ZeroPrice, error)
|
||||
deleteZeroPricesPeriod(ctx context.Context, userId int64, start, end time.Time, now sql.NullTime) error
|
||||
deleteZeroPrices(ctx context.Context, now sql.NullTime, list []int64) error
|
||||
deleteZeroPrices(ctx context.Context, userId int64, now sql.NullTime, list []int64) error
|
||||
}
|
||||
|
||||
func (r *repo) insertPrices(ctx context.Context, prices []Price) error {
|
||||
|
|
@ -192,10 +192,17 @@ func (r *repo) deleteZeroPricesPeriod(ctx context.Context, userId int64, start,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *repo) deleteZeroPrices(ctx context.Context, now sql.NullTime, list []int64) error {
|
||||
q := `UPDATE merch_prices SET deleted_at = $1 WHERE id IN $2`
|
||||
func (r *repo) deleteZeroPrices(ctx context.Context, userId int64, now sql.NullTime, list []int64) error {
|
||||
q := `
|
||||
UPDATE merch_prices mp
|
||||
SET deleted_at = $1
|
||||
FROM merch m
|
||||
WHERE mp.id = ANY($2)
|
||||
AND mp.merch_id = m.id
|
||||
AND m.user_id = $3
|
||||
`
|
||||
|
||||
_, err := r.db.Exec(ctx, q, now, list)
|
||||
_, err := r.db.Exec(ctx, q, now, list, userId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue