Add error display to file upload
This commit is contained in:
parent
344f4bcaa5
commit
66d35428fa
7 changed files with 93 additions and 28 deletions
|
|
@ -192,9 +192,11 @@ func JobImport(ctx context.Context, txn bob.Executor, file_id int32) error {
|
|||
err = importCSV(ctx, file_id, parseCSVFlyover, processCSVFlyover)
|
||||
}
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msg("failed to import CSV")
|
||||
_, err := psql.Update(
|
||||
um.Table("fileupload.file"),
|
||||
um.SetCol("status").ToArg("error"),
|
||||
um.SetCol("error").ToArg(err.Error()),
|
||||
um.Where(psql.Quote("id").EQ(psql.Arg(file_id))),
|
||||
).Exec(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ const (
|
|||
|
||||
type Upload struct {
|
||||
Created time.Time `db:"created" json:"created"`
|
||||
Error string `db:"error" json:"error"`
|
||||
Filename string `db:"filename" json:"filename"`
|
||||
ID int32 `db:"id" json:"id"`
|
||||
RecordCount int `db:"recordcount" json:"recordcount"`
|
||||
|
|
@ -92,6 +93,7 @@ func NewUpload(ctx context.Context, u User, upload file.Upload, t enums.Fileuplo
|
|||
Created: omit.From(time.Now()),
|
||||
CreatorID: omit.From(int32(u.ID)),
|
||||
Deleted: omitnull.FromPtr[time.Time](nil),
|
||||
Error: omit.From(""),
|
||||
Name: omit.From(upload.Name),
|
||||
OrganizationID: omit.From(u.Organization.ID),
|
||||
Status: omit.From(enums.FileuploadFilestatustypeUploaded),
|
||||
|
|
@ -167,6 +169,7 @@ func UploadList(ctx context.Context, org Organization) ([]Upload, error) {
|
|||
"file.created AS created",
|
||||
//"file.creator_id",
|
||||
//"file.deleted",
|
||||
"file.error AS error",
|
||||
"file.id AS id",
|
||||
"file.name AS filename",
|
||||
//"file.organization_id",
|
||||
|
|
@ -235,9 +238,9 @@ func getUploadDetailPool(ctx context.Context, file *models.FileuploadFile) (*Upl
|
|||
Tags: tags,
|
||||
})
|
||||
}
|
||||
log.Debug().Str("status", file.Status.String()).Int32("id", file.ID).Msg("returning")
|
||||
return &Upload{
|
||||
Created: file.Created,
|
||||
Error: file.Error,
|
||||
Filename: file.Name,
|
||||
ID: file.ID,
|
||||
RecordCount: len(pool_rows),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue