package resolver // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" "time" "edge-infra.dev/pkg/edge/api/graph/model" "edge-infra.dev/pkg/edge/api/graph/pagination" "edge-infra.dev/pkg/edge/api/middleware" "edge-infra.dev/pkg/edge/bsl" "github.com/rs/zerolog/log" ) // Actions is the resolver for the actions field. func (r *queryResolver) Actions(ctx context.Context, username *string, bannerEdgeID *string, clusterEdgeID *string, batchID *string, action *string, status *string, cursor *string, count *int) (*model.Actions, error) { orgName := bsl.GetOrgShortName(middleware.ForContext(ctx).Organization) tenant, err := r.BannerService.GetBannerTenantInfo(ctx, orgName) if err != nil { log.Ctx(ctx).Err(err).Msg("failed to get tenantEdgeID") return nil, err } currentCursor, limit := pagination.Parse(cursor, count) actions, totalCount, err := r.ActivityService.GetActions(ctx, username, bannerEdgeID, clusterEdgeID, batchID, action, status, tenant.TenantEdgeID, currentCursor.Cursor, limit, currentCursor.Previous) if err != nil { log.Ctx(ctx).Err(err).Msg("failed to get actions") return nil, err } ends := currentCursor.Cursor previousTime := "" if len(actions) > 0 { ends = actions[len(actions)-1].Time } if len(actions) > 0 && currentCursor.Offset != 0 { previousTime = actions[0].Time } endTime, err := time.Parse(time.RFC3339, ends) if err != nil { log.Ctx(ctx).Err(err).Msg("failed to parse time") return nil, err } pageInfo := pagination.Overall(currentCursor, endTime.Format(time.RFC3339), previousTime, len(actions), totalCount, currentCursor.Offset) return &model.Actions{ Edges: actions, PageInfo: pageInfo, }, nil }