71f9802e1a
Split Query Running + Debugging Full Flow * completedquerysyncrunner * spliitinglogic * synccomplete * informdependents * only push same collector * deps * livetesting * foundissue * some issues resolved * activeupdate * collectorupdatefixes * fix dbquesries * tests * tests * pollingdebug
46 lines
823 B
Go
46 lines
823 B
Go
package documentclean
|
|
|
|
import (
|
|
"context"
|
|
doctextrunner "queryorchestration/api/docTextRunner"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/serviceconfig/queue"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func (s *Service) Clean(ctx context.Context, id uuid.UUID) error {
|
|
isclean, err := s.cfg.GetDBQueries().IsDocumentClean(ctx, database.MustToDBUUID(id))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !isclean {
|
|
err = s.clean(ctx, id)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
err = s.informClean(ctx, id)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *Service) informClean(ctx context.Context, id uuid.UUID) error {
|
|
err := s.cfg.SendToQueue(ctx, &queue.SendParams{
|
|
QueueURL: s.cfg.GetDocumentTextURL(),
|
|
Body: doctextrunner.Body{
|
|
ID: id,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|