Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(run): run logging data list by credit owner API #695

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0
github.com/iancoleman/strcase v0.3.0
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240902051229-d15d37e2778e
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241012090311-e872dc0b511d
github.com/instill-ai/usage-client v0.3.0-alpha
github.com/instill-ai/x v0.4.0-alpha.0.20240923052503-fd243919e005
github.com/jackc/pgx/v5 v5.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ github.com/hjson/hjson-go/v4 v4.0.0 h1:wlm6IYYqHjOdXH1gHev4VoXCaW20HdQAGCxdOEEg2
github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240902051229-d15d37e2778e h1:vOhL04/gbXioWBY0fkbOwL9/E6DTIkOnNMQEIKZv3iM=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240902051229-d15d37e2778e/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241012090311-e872dc0b511d h1:jf2RQtRFNxnPMkjTD0AAqXDXO8lHYOrWU3Hrr+yGEzY=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241012090311-e872dc0b511d/go.mod h1:rf0UY7VpEgpaLudYEcjx5rnbuwlBaaLyD4FQmWLtgAY=
github.com/instill-ai/usage-client v0.3.0-alpha h1:yY5eNn5zINqy8wpOogiNmrVYzJKnd1KMnMxlYBpr7Tk=
github.com/instill-ai/usage-client v0.3.0-alpha/go.mod h1:8lvtZulkhQ7t8alttb2KkLKYoCp5u4oatzDbfFlEld0=
github.com/instill-ai/x v0.4.0-alpha.0.20240923052503-fd243919e005 h1:6iUpJs545Ivvv2joJCQoawRPr2YRPjux22k7t+gWg6s=
Expand Down
1 change: 1 addition & 0 deletions pkg/datamodel/modelrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type ModelRun struct {
InputReferenceID string
OutputReferenceID null.String
Error null.String
Model Model `gorm:"foreignKey:ModelUID;references:UID"`
}

func (*ModelRun) TableName() string {
Expand Down
15 changes: 15 additions & 0 deletions pkg/handler/mock_service_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions pkg/handler/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,3 +1141,50 @@ func (h *PublicHandler) ListModelRuns(ctx context.Context, req *modelpb.ListMode

return resp, nil
}

func (h *PublicHandler) ListModelRunsByCreditOwner(ctx context.Context, req *modelpb.ListModelRunsByCreditOwnerRequest) (*modelpb.ListModelRunsByCreditOwnerResponse, error) {

eventName := "ListModelRunsByCreditOwner"

ctx, span := tracer.Start(ctx, eventName,
trace.WithSpanKind(trace.SpanKindServer))
defer span.End()

logger, _ := custom_logger.GetZapLogger(ctx)

if err := authenticateUser(ctx, true); err != nil {
span.SetStatus(1, err.Error())
return nil, err
}

declarations, err := filtering.NewDeclarations([]filtering.DeclarationOption{
filtering.DeclareStandardFunctions(),
filtering.DeclareIdent("status", filtering.TypeString),
filtering.DeclareIdent("source", filtering.TypeString),
}...)
if err != nil {
return nil, err
}

filter, err := filtering.ParseFilter(req, declarations)
if err != nil {
return nil, err
}

resp, err := h.service.ListModelRunsByCreditOwner(ctx, req, filter)
if err != nil {
span.SetStatus(1, err.Error())
return nil, err
}

logUUID, _ := uuid.NewV4()
logger.Info(string(custom_otel.NewLogMessage(
ctx,
span,
logUUID.String(),
eventName,
custom_otel.SetEventMessage(fmt.Sprintf("%s done", eventName)),
)))

return resp, nil
}
Loading
Loading