Merged in feature/richname (pull request #112)
Standardised rich name for Files * tests
This commit is contained in:
@@ -8,17 +8,16 @@ import (
|
||||
|
||||
docsyncrunner "queryorchestration/api/docSyncRunner"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/document"
|
||||
"queryorchestration/internal/serviceconfig/objectstore"
|
||||
"queryorchestration/internal/serviceconfig/queue"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Create struct {
|
||||
ClientID string
|
||||
Location document.Location
|
||||
Bucket string
|
||||
Hash string
|
||||
Bucket string
|
||||
Key objectstore.BucketKey
|
||||
Hash string
|
||||
}
|
||||
|
||||
func (s *Service) Create(ctx context.Context, doc *Create) (uuid.UUID, error) {
|
||||
@@ -48,15 +47,15 @@ func (s *Service) Create(ctx context.Context, doc *Create) (uuid.UUID, error) {
|
||||
}
|
||||
|
||||
type createDocumentParams struct {
|
||||
ID *uuid.UUID
|
||||
ClientID string
|
||||
Hash string
|
||||
Location document.Location
|
||||
ID *uuid.UUID
|
||||
Hash string
|
||||
Bucket string
|
||||
Key objectstore.BucketKey
|
||||
}
|
||||
|
||||
func (s *Service) getCreateParams(ctx context.Context, doc *Create) (*createDocumentParams, error) {
|
||||
idbyhash, err := s.cfg.GetDBQueries().GetDocumentIDByHash(ctx, &repository.GetDocumentIDByHashParams{
|
||||
Clientid: doc.ClientID,
|
||||
Clientid: doc.Key.ClientID,
|
||||
Hash: doc.Hash,
|
||||
})
|
||||
var docID *uuid.UUID
|
||||
@@ -67,10 +66,10 @@ func (s *Service) getCreateParams(ctx context.Context, doc *Create) (*createDocu
|
||||
}
|
||||
|
||||
return &createDocumentParams{
|
||||
ID: docID,
|
||||
ClientID: doc.ClientID,
|
||||
Hash: doc.Hash,
|
||||
Location: doc.Location,
|
||||
ID: docID,
|
||||
Hash: doc.Hash,
|
||||
Key: doc.Key,
|
||||
Bucket: doc.Bucket,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -81,25 +80,25 @@ func (s *Service) submitCreate(ctx context.Context, params *createDocumentParams
|
||||
var dbid uuid.UUID
|
||||
if params.ID == nil {
|
||||
createid, err := s.cfg.GetDBQueries().CreateDocument(ctx, &repository.CreateDocumentParams{
|
||||
Clientid: params.ClientID,
|
||||
Clientid: params.Key.ClientID,
|
||||
Hash: params.Hash,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
slog.Debug("document created", "id", createid.String(), "client", params.ClientID)
|
||||
slog.Debug("document created", "id", createid.String(), "client", params.Key.ClientID)
|
||||
|
||||
dbid = createid
|
||||
} else {
|
||||
slog.Debug("document exists", "id", params.ID.String(), "client", params.ClientID)
|
||||
slog.Debug("document exists", "id", params.ID.String(), "client", params.Key.ClientID)
|
||||
|
||||
dbid = *params.ID
|
||||
}
|
||||
|
||||
err := s.cfg.GetDBQueries().AddDocumentEntry(ctx, &repository.AddDocumentEntryParams{
|
||||
Documentid: dbid,
|
||||
Bucket: params.Location.Bucket,
|
||||
Key: params.Location.Key,
|
||||
Bucket: params.Bucket,
|
||||
Key: params.Key.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user