Merged in feature/batch-status (pull request #215)

Implement and test the batch status feature

* working
This commit is contained in:
Jay Brown
2026-03-12 18:53:42 +00:00
parent 8a4029058b
commit aafe7d5b5f
39 changed files with 4252 additions and 516 deletions
+26 -6
View File
@@ -10,20 +10,40 @@ import (
"github.com/google/uuid"
)
func (s *Service) Sync(ctx context.Context, id uuid.UUID) error {
// SyncResult contains the result of the sync check.
//
// Fields:
// - Synced: true if the document was forwarded to the clean queue
// - Skipped: true if the client's can_sync flag is false
type SyncResult struct {
Synced bool
Skipped bool
}
// Sync checks if a document is eligible for syncing based on the client's
// can_sync configuration, and forwards eligible documents to the clean queue.
//
// Parameters:
// - ctx: request context
// - id: the document UUID to sync
//
// Returns:
// - *SyncResult: result indicating whether sync was performed or skipped
// - error: if any infrastructure operation (DB, queue) fails
func (s *Service) Sync(ctx context.Context, id uuid.UUID) (*SyncResult, error) {
doc, err := s.svc.Document.GetSummary(ctx, id)
if err != nil {
return err
return nil, err
}
j, err := s.svc.Client.Get(ctx, doc.ClientID)
if err != nil {
return err
return nil, err
}
if !j.CanSync {
slog.Debug("not syncing document", "id", id.String())
return nil
return &SyncResult{Skipped: true}, nil
}
slog.Debug("syncing document", "id", id.String())
@@ -35,8 +55,8 @@ func (s *Service) Sync(ctx context.Context, id uuid.UUID) error {
},
})
if err != nil {
return err
return nil, err
}
return nil
return &SyncResult{Synced: true}, nil
}