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
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package documentclean
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/document"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CleanParams struct {
|
|
ID uuid.UUID
|
|
Location document.Location
|
|
}
|
|
|
|
func (s *Service) executeCleanTasks(params *CleanParams) (*document.Location, error) {
|
|
// TODO - various cleaning tasks
|
|
return ¶ms.Location, nil
|
|
}
|
|
|
|
func (s *Service) clean(ctx context.Context, id uuid.UUID) error {
|
|
slog.Debug("cleaning document", "id", id.String())
|
|
|
|
docId := database.MustToDBUUID(id)
|
|
|
|
entry, err := s.cfg.GetDBQueries().GetDocumentEntry(ctx, docId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
outLocation, err := s.executeCleanTasks(&CleanParams{
|
|
ID: id,
|
|
Location: document.Location{
|
|
Bucket: entry.Bucket,
|
|
Key: entry.Key,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
version := s.svc.Document.GetCleanVersion()
|
|
|
|
err = s.cfg.GetDBQueries().AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{
|
|
Documentid: docId,
|
|
Version: version,
|
|
Bucket: outLocation.Bucket,
|
|
Key: outLocation.Key,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|