53ea7d34e6
Start adding Textract + UUID changes * base * startclient * ts * short * tests
41 lines
909 B
Go
41 lines
909 B
Go
package query
|
|
|
|
import (
|
|
"context"
|
|
|
|
"queryorchestration/internal/database/repository"
|
|
resultprocessor "queryorchestration/internal/query/result/processor"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Query struct {
|
|
ID uuid.UUID
|
|
Type resultprocessor.Type
|
|
ActiveVersion int32
|
|
LatestVersion int32
|
|
RequiredQueryIDs *[]uuid.UUID
|
|
Config *string
|
|
}
|
|
|
|
func (s *Service) GetWithVersion(ctx context.Context, id uuid.UUID, version int32) (*Query, error) {
|
|
query, err := s.cfg.GetDBQueries().GetQueryWithVersion(ctx, &repository.GetQueryWithVersionParams{
|
|
ID: &id,
|
|
Version: &version,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ParseQueryWithVersion(query)
|
|
}
|
|
|
|
func (s *Service) Get(ctx context.Context, id uuid.UUID) (*Query, error) {
|
|
query, err := s.cfg.GetDBQueries().GetQuery(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ParseFullActiveQuery(query)
|
|
}
|