3d434eedb8
Job Status Get and DB tidy up * initalquery * tests * shorttests * testing queries * job * solvedthequery * updatingdb * fixingtests * repotests * shorttests * docker * testspassed
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package documenttext
|
|
|
|
import (
|
|
"context"
|
|
"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) {
|
|
// TODO - various extraction tasks
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|