stubbed updating of saved mock listing
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -354,8 +355,8 @@ func (db *Store) ListMockListingsForShop(ctx context.Context, acctID int64, plat
|
||||
ON
|
||||
TRUE
|
||||
WHERE
|
||||
account_id = @account_id
|
||||
AND shop_id = @shop_id
|
||||
(account_id IS NULL OR account_id = @account_id)
|
||||
AND (shop_id IS NULL OR shop_id = @shop_id)
|
||||
`,
|
||||
shopTableName,
|
||||
listingsTableName,
|
||||
@@ -371,11 +372,11 @@ func (db *Store) ListMockListingsForShop(ctx context.Context, acctID int64, plat
|
||||
|
||||
vs, err := pgx.CollectRows(rows, pgx.RowToStructByNameLax[struct {
|
||||
Shop_exists bool
|
||||
Listing_id string
|
||||
SKU string
|
||||
Name string
|
||||
Description string
|
||||
Count int64
|
||||
Listing_id pgtype.Text
|
||||
SKU pgtype.Text
|
||||
Name pgtype.Text
|
||||
Description pgtype.Text
|
||||
Count pgtype.Int8
|
||||
}])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to scan rows: %w", err)
|
||||
@@ -384,9 +385,10 @@ func (db *Store) ListMockListingsForShop(ctx context.Context, acctID int64, plat
|
||||
// check if the shop exists, and confirm there were actually listings (LEFT JOIN)
|
||||
|
||||
if len(vs) == 0 || !vs[0].Shop_exists {
|
||||
fmt.Println("TEST")
|
||||
return nil, fmt.Errorf("%w: shop not found", consts.ErrNotFound)
|
||||
}
|
||||
if vs[0].SKU == "" {
|
||||
if !vs[0].SKU.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -401,12 +403,12 @@ func (db *Store) ListMockListingsForShop(ctx context.Context, acctID int64, plat
|
||||
Platform: platform,
|
||||
ShopID: shopID,
|
||||
},
|
||||
ListingID: v.Listing_id,
|
||||
ListingID: v.Listing_id.String,
|
||||
},
|
||||
SKU: v.SKU,
|
||||
Name: v.Name,
|
||||
Description: v.Description,
|
||||
Count: v.Count,
|
||||
SKU: v.SKU.String,
|
||||
Name: v.Name.String,
|
||||
Description: v.Description.String,
|
||||
Count: v.Count.Int64,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user