f11f4def43
Clean Set Up * fail * starteddb * constraint * cleantest * fixqueries * fixtests * storemimetype * buffer * tests * setup * passingtests * pdfHElloWorld * rm * test * notodos * tests * clean * testpdf
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package documenttext
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/document"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type ExtractionParams struct {
|
|
ID uuid.UUID
|
|
Location document.Location
|
|
}
|
|
|
|
func (s *Service) executeExtraction(params *ExtractionParams) (*document.Location, error) {
|
|
return ¶ms.Location, nil
|
|
}
|
|
|
|
func (s *Service) extract(ctx context.Context, id uuid.UUID) error {
|
|
docId := database.MustToDBUUID(id)
|
|
|
|
entry, err := s.cfg.GetDBQueries().GetDocumentCleanEntry(ctx, docId)
|
|
if err != nil {
|
|
return err
|
|
} else if entry.Fail.Valid {
|
|
return fmt.Errorf("no valid cleaning")
|
|
}
|
|
|
|
outLocation, err := s.executeExtraction(&ExtractionParams{
|
|
ID: id,
|
|
Location: document.Location{
|
|
Bucket: *entry.Bucket,
|
|
Key: *entry.Key,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
version := s.svc.Version.GetVersion()
|
|
|
|
err = s.cfg.GetDBQueries().AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{
|
|
Version: version,
|
|
Bucket: outLocation.Bucket,
|
|
Key: outLocation.Key,
|
|
Cleanentryid: entry.ID,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|