fee71e7740
Feature/postprocessing * tests * passtest * fixshorttests * mosttests * improvingbasedockerfile * testspeeds * testing * host * canparallel * clean * passfullsuite * singlepagemax * test * findfeatures * findstables * tbls * tablestoo * tablestoo * lateraltests * tableloc * cleanup * inlinetable * childids * cleanup * tests
44 lines
878 B
Go
44 lines
878 B
Go
package documenttext
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
querysyncrunner "queryorchestration/api/querySyncRunner"
|
|
"queryorchestration/internal/serviceconfig/queue"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func (s *Service) Extract(ctx context.Context, documentId uuid.UUID) error {
|
|
slog.Debug("extracting document text", "id", documentId.String())
|
|
|
|
isextracted, err := s.cfg.GetDBQueries().IsDocumentTextExtracted(ctx, documentId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !isextracted {
|
|
err = s.executeExtraction(ctx, documentId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return s.informExtraction(ctx, documentId)
|
|
}
|
|
|
|
func (s *Service) informExtraction(ctx context.Context, id uuid.UUID) error {
|
|
err := s.cfg.SendToQueue(ctx, &queue.SendParams{
|
|
QueueURL: s.cfg.GetQuerySyncURL(),
|
|
Body: querysyncrunner.Body{
|
|
DocumentID: id,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|