2026-01-15 20:39:32 +00:00
|
|
|
// Package documentclean provides document cleaning functionality.
|
|
|
|
|
// Note: Text extraction pipeline has been removed. The document processing
|
|
|
|
|
// pipeline now ends after cleaning. See remove_texttract_and_mocks_plan.md.
|
2025-02-07 12:12:51 +00:00
|
|
|
package documentclean
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-05-20 12:47:22 +00:00
|
|
|
"fmt"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-02-07 12:12:51 +00:00
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-15 20:39:32 +00:00
|
|
|
// Clean processes a document by cleaning it. Previously this also triggered
|
|
|
|
|
// text extraction, but that feature has been removed.
|
2025-04-02 18:50:03 +00:00
|
|
|
func (s *Service) Clean(ctx context.Context, documentId uuid.UUID) error {
|
|
|
|
|
isclean, err := s.cfg.GetDBQueries().HasDocumentCleanEntry(ctx, documentId)
|
2025-02-07 12:12:51 +00:00
|
|
|
if err != nil {
|
2025-06-23 15:58:20 +00:00
|
|
|
return fmt.Errorf("unable to verify if document has been cleaned: %w", err)
|
2025-02-07 12:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !isclean {
|
2025-04-02 18:50:03 +00:00
|
|
|
err = s.clean(ctx, documentId)
|
2025-02-07 12:12:51 +00:00
|
|
|
if err != nil {
|
2025-06-23 15:58:20 +00:00
|
|
|
return fmt.Errorf("unable to clean document: %w", err)
|
2025-02-07 12:12:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 20:39:32 +00:00
|
|
|
// Note: Text extraction has been removed. Document pipeline ends here.
|
2025-02-07 12:12:51 +00:00
|
|
|
return nil
|
|
|
|
|
}
|