47 lines
970 B
Go
47 lines
970 B
Go
package result
|
|
|
|
import (
|
|
"context"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Result struct {
|
|
ID uuid.UUID
|
|
QueryID uuid.UUID
|
|
QueryVersion int32
|
|
}
|
|
|
|
type Value interface {
|
|
GetValue(ctx context.Context) (string, error)
|
|
}
|
|
|
|
type ResultStore struct {
|
|
QueryID uuid.UUID
|
|
DocumentID uuid.UUID
|
|
Value string
|
|
CleanVersion int32
|
|
TextVersion int32
|
|
QueryVersion int32
|
|
}
|
|
|
|
func Store(ctx context.Context, db *repository.Queries, res *ResultStore) (uuid.UUID, error) {
|
|
dbId, err := db.SetResult(ctx, repository.SetResultParams{
|
|
Queryid: database.MustToDBUUID(res.QueryID),
|
|
Documentid: database.MustToDBUUID(res.DocumentID),
|
|
Value: res.Value,
|
|
Cleanversion: res.CleanVersion,
|
|
Textversion: res.TextVersion,
|
|
Queryversion: res.QueryVersion,
|
|
})
|
|
if err != nil {
|
|
return uuid.Nil, err
|
|
}
|
|
|
|
id := database.MustToUUID(dbId)
|
|
|
|
return id, nil
|
|
}
|