This commit is contained in:
jay brown
2025-08-04 10:54:22 -07:00
parent 582e5b77c0
commit 56fb9b4ab6
20 changed files with 1026 additions and 28 deletions
+74 -3
View File
@@ -12,6 +12,61 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
type BatchStatus string
const (
BatchStatusProcessing BatchStatus = "processing"
BatchStatusCompleted BatchStatus = "completed"
BatchStatusFailed BatchStatus = "failed"
BatchStatusCancelled BatchStatus = "cancelled"
)
func (e *BatchStatus) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = BatchStatus(s)
case string:
*e = BatchStatus(s)
default:
return fmt.Errorf("unsupported scan type for BatchStatus: %T", src)
}
return nil
}
type NullBatchStatus struct {
BatchStatus BatchStatus
Valid bool // Valid is true if BatchStatus is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullBatchStatus) Scan(value interface{}) error {
if value == nil {
ns.BatchStatus, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.BatchStatus.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullBatchStatus) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.BatchStatus), nil
}
func (e BatchStatus) Valid() bool {
switch e {
case BatchStatusProcessing,
BatchStatusCompleted,
BatchStatusFailed,
BatchStatusCancelled:
return true
}
return false
}
type Cleanfailtype string
const (
@@ -177,6 +232,21 @@ func (e Querytype) Valid() bool {
return false
}
type BatchUpload struct {
ID uuid.UUID `db:"id"`
ClientID string `db:"client_id"`
OriginalFilename string `db:"original_filename"`
TotalDocuments int32 `db:"total_documents"`
ProcessedDocuments int32 `db:"processed_documents"`
FailedDocuments int32 `db:"failed_documents"`
InvalidTypeDocuments int32 `db:"invalid_type_documents"`
Status BatchStatus `db:"status"`
ProgressPercent int32 `db:"progress_percent"`
FailedFilenames []byte `db:"failed_filenames"`
CreatedAt pgtype.Timestamp `db:"created_at"`
CompletedAt pgtype.Timestamp `db:"completed_at"`
}
type Client struct {
Clientid string `db:"clientid"`
Name string `db:"name"`
@@ -292,9 +362,10 @@ type Currenttextentry struct {
}
type Document struct {
ID uuid.UUID `db:"id"`
Clientid string `db:"clientid"`
Hash string `db:"hash"`
ID uuid.UUID `db:"id"`
Clientid string `db:"clientid"`
Hash string `db:"hash"`
BatchID *uuid.UUID `db:"batch_id"`
}
type Documentclean struct {