Merged in feature/splitqueryrunning (pull request #57)
Split Query Running + Debugging Full Flow * completedquerysyncrunner * spliitinglogic * synccomplete * informdependents * only push same collector * deps * livetesting * foundissue * some issues resolved * activeupdate * collectorupdatefixes * fix dbquesries * tests * tests * pollingdebug
This commit is contained in:
@@ -2,6 +2,7 @@ package collector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/validation"
|
||||
@@ -68,6 +69,39 @@ func (s *Service) getCreateParams(ctx context.Context, params *CreateParams) (*d
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) normalizeFieldsToDB(ctx context.Context, ofields *map[string]uuid.UUID) (*map[string]pgtype.UUID, error) {
|
||||
if ofields == nil || *ofields == nil {
|
||||
return nil, nil
|
||||
} else if len(*ofields) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
dbm := map[string]pgtype.UUID{}
|
||||
for name, id := range *ofields {
|
||||
dbm[name] = database.MustToDBUUID(id)
|
||||
}
|
||||
|
||||
dbids := []pgtype.UUID{}
|
||||
for _, id := range dbm {
|
||||
dbids = append(dbids, id)
|
||||
}
|
||||
|
||||
dedup := validation.DeduplicateArray(dbids)
|
||||
|
||||
if len(dedup) != len(dbids) {
|
||||
return nil, errors.New("duplicate output fields")
|
||||
}
|
||||
|
||||
exist, err := s.cfg.GetDBQueries().AllQueriesExist(ctx, dbids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !exist {
|
||||
return nil, errors.New("not all required ids are present")
|
||||
}
|
||||
|
||||
return &dbm, nil
|
||||
}
|
||||
|
||||
func (s *Service) submitCreate(ctx context.Context, params *dbCreateParams) (uuid.UUID, error) {
|
||||
var dbID pgtype.UUID
|
||||
err := s.cfg.ExecuteDBTransaction(ctx, func(ctx context.Context, qtx *repository.Queries) error {
|
||||
|
||||
Reference in New Issue
Block a user