move common code to pkg
This commit is contained in:
@@ -3,7 +3,7 @@ package meteo
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"servicea/internal/domains"
|
||||
"pkg"
|
||||
"strings"
|
||||
|
||||
b "github.com/jackc/pgx/v5"
|
||||
@@ -78,7 +78,7 @@ func (pgx *pgxRepo) insertBatch(ctx context.Context, tx b.Tx, fileChecksum strin
|
||||
var batchID int
|
||||
err := tx.QueryRow(ctx, insertBatch, 0, fileChecksum).Scan(&batchID)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), domains.SQLSTATE_23505) {
|
||||
if strings.Contains(err.Error(), pkg.SQLSTATE_23505) {
|
||||
return 0, ErrRecordAlreadyExists
|
||||
}
|
||||
return 0, fmt.Errorf("error inserting batch: %w", err)
|
||||
@@ -107,7 +107,7 @@ func (pgx *pgxRepo) insertAcceptedMeteoData(ctx context.Context, tx b.Tx, batchI
|
||||
rowsInserted++
|
||||
if err != nil {
|
||||
results.Close()
|
||||
if strings.Contains(err.Error(), domains.SQLSTATE_23505) {
|
||||
if strings.Contains(err.Error(), pkg.SQLSTATE_23505) {
|
||||
return 0, ErrRecordAlreadyExists
|
||||
}
|
||||
return 0, fmt.Errorf("error executing batch command %d: %w", i, err)
|
||||
|
||||
Reference in New Issue
Block a user