Fix setting the file to "parsed" when starting parse job
This commit is contained in:
parent
96514d61e2
commit
8e00d3e04b
2 changed files with 8 additions and 4 deletions
|
|
@ -96,15 +96,16 @@ func startWorkerCSV(ctx context.Context, channelJobImport chan jobCSV) {
|
||||||
log.Info().Msg("CSV worker shutting down.")
|
log.Info().Msg("CSV worker shutting down.")
|
||||||
return
|
return
|
||||||
case job := <-channelJobImport:
|
case job := <-channelJobImport:
|
||||||
log.Info().Int32("id", job.fileID).Msg("Processing CSV job")
|
|
||||||
switch job.action {
|
switch job.action {
|
||||||
case jobCSVActionCommit:
|
case jobCSVActionCommit:
|
||||||
|
log.Info().Int32("id", job.fileID).Msg("Processing CSV commit job")
|
||||||
err := csv.JobCommit(ctx, job.fileID)
|
err := csv.JobCommit(ctx, job.fileID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Int32("id", job.fileID).Msg("Error processing CSV file")
|
log.Error().Err(err).Int32("id", job.fileID).Msg("Error processing CSV file")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case jobCSVActionImport:
|
case jobCSVActionImport:
|
||||||
|
log.Info().Int32("id", job.fileID).Msg("Processing CSV import job")
|
||||||
err := csv.JobImport(ctx, job.fileID, job.csvType)
|
err := csv.JobImport(ctx, job.fileID, job.csvType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Int32("id", job.fileID).Msg("Error processing CSV file")
|
log.Error().Err(err).Int32("id", job.fileID).Msg("Error processing CSV file")
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,13 @@ func JobImport(ctx context.Context, file_id int32, type_ enums.FileuploadCsvtype
|
||||||
func importCSV[T any](ctx context.Context, file_id int32, parser csvParserFunc[T], processor csvProcessorFunc[T]) error {
|
func importCSV[T any](ctx context.Context, file_id int32, parser csvParserFunc[T], processor csvProcessorFunc[T]) error {
|
||||||
// Not done in the transaction so the state shows up immediately
|
// Not done in the transaction so the state shows up immediately
|
||||||
_, err := psql.Update(
|
_, err := psql.Update(
|
||||||
um.Table("fileupload.csv"),
|
um.Table("fileupload.file"),
|
||||||
um.SetCol("status").ToArg("processing"),
|
um.SetCol("status").ToArg("parsing"),
|
||||||
um.Where(psql.Quote("file_id").EQ(psql.Arg(file_id))),
|
um.Where(psql.Quote("id").EQ(psql.Arg(file_id))),
|
||||||
).Exec(ctx, db.PGInstance.BobDB)
|
).Exec(ctx, db.PGInstance.BobDB)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to set file %d to processing: %w", file_id, err)
|
||||||
|
}
|
||||||
|
|
||||||
file, c, err := loadFileAndCSV(ctx, file_id)
|
file, c, err := loadFileAndCSV(ctx, file_id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue