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

refactor: update code syntax in backend server #4944

Open
wants to merge 7 commits into
base: master
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
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ func (c *ChaosExperimentHandler) StopExperimentRuns(ctx context.Context, project
if len(experimentRunsID) == 0 && experiment.CronSyntax == "" {
return false, fmt.Errorf("no running or timeout experiments found")
}
} else if experimentRunID != nil && *experimentRunID != "" {
} else if *experimentRunID != "" {
amityt marked this conversation as resolved.
Show resolved Hide resolved
experimentRunsID = []string{*experimentRunID}
}

Expand Down
10 changes: 6 additions & 4 deletions chaoscenter/graphql/server/pkg/environment/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
}

// Filtering based on given parameters
if request.Filter != nil {
if request != nil && request.Filter != nil {
// Filtering based on chaos_infra name
if request.Filter.Name != nil && *request.Filter.Name != "" {
matchInfraNameStage := bson.D{
Expand Down Expand Up @@ -280,7 +280,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
var sortStage bson.D

switch {
case request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldTime:
case request != nil && request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldTime:
// Sorting based on created time
if request.Sort.Ascending != nil && *request.Sort.Ascending {
sortStage = bson.D{
Expand All @@ -295,7 +295,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
}},
}
}
case request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldName:
case request != nil && request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldName:
// Sorting based on ExperimentName time
if request.Sort.Ascending != nil && *request.Sort.Ascending {
sortStage = bson.D{
Expand Down Expand Up @@ -324,7 +324,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
sortStage,
}

if request.Pagination != nil {
if request != nil && request.Pagination != nil {
paginationSkipStage := bson.D{
{"$skip", request.Pagination.Page * request.Pagination.Limit},
}
Expand Down Expand Up @@ -353,6 +353,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
pipeline = append(pipeline, facetStage)

cursor, err := e.EnvironmentOperator.GetAggregateEnvironments(pipeline)

if err != nil {
return nil, err
}
Expand All @@ -368,6 +369,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
Environments: envs,
}, errors.New("error decoding environment cursor: " + err.Error())
}

if len(aggregatedEnvironments) == 0 {
return &model.ListEnvironmentResponse{
TotalNoOfEnvironments: 0,
Expand Down
3 changes: 1 addition & 2 deletions chaoscenter/graphql/server/pkg/gitops/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,11 @@ func (g *gitOpsService) updateExperiment(ctx context.Context, data, wfID, file s
}

revID := ""
updateRevision := false
input, wfType, err := g.chaosExperimentService.ProcessExperiment(ctx, &experimentData, config.ProjectID, revID)
if err != nil {
return err
}
return g.chaosExperimentService.ProcessExperimentUpdate(input, "git-ops", wfType, revID, updateRevision, config.ProjectID, dataStore.Store)
return g.chaosExperimentService.ProcessExperimentUpdate(input, "git-ops", wfType, revID, false, config.ProjectID, dataStore.Store)
}

// deleteExperiment helps in deleting experiment from DB during the SyncDBToGit operation
Expand Down
Loading