feat: predictor works
This commit is contained in:
parent
11be8f351f
commit
7a9f81e527
20 changed files with 1357 additions and 1794 deletions
|
|
@ -32,15 +32,15 @@ func (c *codeRecorder) WriteHeader(status int) {
|
|||
|
||||
// handlePerformPredictionRequest handles performPrediction operation.
|
||||
//
|
||||
// Perform preidction.
|
||||
// Perform prediction.
|
||||
//
|
||||
// POST /api/v1/prediction
|
||||
// GET /api/v1/prediction
|
||||
func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("performPrediction"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/prediction"),
|
||||
}
|
||||
|
||||
|
|
@ -114,41 +114,82 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
request, close, err := s.decodePerformPredictionRequest(r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeRequestError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
defer recordError("DecodeRequest", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := close(); err != nil {
|
||||
recordError("CloseRequest", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var response *PredictionResult
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: PerformPredictionOperation,
|
||||
OperationSummary: "Perform preidction",
|
||||
OperationSummary: "Perform prediction",
|
||||
OperationID: "performPrediction",
|
||||
Body: request,
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "parameters",
|
||||
Name: "launch_latitude",
|
||||
In: "query",
|
||||
}: params.Parameters,
|
||||
}: params.LaunchLatitude,
|
||||
{
|
||||
Name: "launch_longitude",
|
||||
In: "query",
|
||||
}: params.LaunchLongitude,
|
||||
{
|
||||
Name: "launch_datetime",
|
||||
In: "query",
|
||||
}: params.LaunchDatetime,
|
||||
{
|
||||
Name: "launch_altitude",
|
||||
In: "query",
|
||||
}: params.LaunchAltitude,
|
||||
{
|
||||
Name: "profile",
|
||||
In: "query",
|
||||
}: params.Profile,
|
||||
{
|
||||
Name: "ascent_rate",
|
||||
In: "query",
|
||||
}: params.AscentRate,
|
||||
{
|
||||
Name: "burst_altitude",
|
||||
In: "query",
|
||||
}: params.BurstAltitude,
|
||||
{
|
||||
Name: "descent_rate",
|
||||
In: "query",
|
||||
}: params.DescentRate,
|
||||
{
|
||||
Name: "float_altitude",
|
||||
In: "query",
|
||||
}: params.FloatAltitude,
|
||||
{
|
||||
Name: "stop_datetime",
|
||||
In: "query",
|
||||
}: params.StopDatetime,
|
||||
{
|
||||
Name: "ascent_curve",
|
||||
In: "query",
|
||||
}: params.AscentCurve,
|
||||
{
|
||||
Name: "descent_curve",
|
||||
In: "query",
|
||||
}: params.DescentCurve,
|
||||
{
|
||||
Name: "interpolate",
|
||||
In: "query",
|
||||
}: params.Interpolate,
|
||||
{
|
||||
Name: "format",
|
||||
In: "query",
|
||||
}: params.Format,
|
||||
{
|
||||
Name: "dataset",
|
||||
In: "query",
|
||||
}: params.Dataset,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = OptPredictionParameters
|
||||
Request = struct{}
|
||||
Params = PerformPredictionParams
|
||||
Response = *PredictionResult
|
||||
)
|
||||
|
|
@ -161,12 +202,12 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
mreq,
|
||||
unpackPerformPredictionParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.PerformPrediction(ctx, request, params)
|
||||
response, err = s.h.PerformPrediction(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.PerformPrediction(ctx, request, params)
|
||||
response, err = s.h.PerformPrediction(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue