81e7223560
Text Extraction * bases * go * splitting * structure * movetoasync * movetoasync * settinguptrigger * reorder * storevent * standardisepollingvalidation * unittests * fixlint * fixlint * awscfg * generatesample * followthrough * tests * clena * store * externalidcleanup * clientid * local * baseunittests * putobjecttests * tests
46 lines
830 B
Go
46 lines
830 B
Go
package documentclean
|
|
|
|
import (
|
|
"context"
|
|
|
|
doctextrunner "queryorchestration/api/docTextRunner"
|
|
"queryorchestration/internal/serviceconfig/queue"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func (s *Service) Clean(ctx context.Context, documentId uuid.UUID) error {
|
|
isclean, err := s.cfg.GetDBQueries().HasDocumentCleanEntry(ctx, documentId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !isclean {
|
|
err = s.clean(ctx, documentId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
err = s.informClean(ctx, documentId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *Service) informClean(ctx context.Context, documentId uuid.UUID) error {
|
|
err := s.cfg.SendToQueue(ctx, &queue.SendParams{
|
|
QueueURL: s.cfg.GetDocumentTextTriggerURL(),
|
|
Body: doctextrunner.Body{
|
|
DocumentID: documentId,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|