Skip to content

Commit

Permalink
refactor: update codes in backend server
Browse files Browse the repository at this point in the history
  • Loading branch information
jemlog committed Nov 15, 2024
1 parent 0c4d175 commit eafa9c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,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 != "" {
experimentRunsID = []string{*experimentRunID}
}

Expand Down
8 changes: 4 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
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

0 comments on commit eafa9c8

Please sign in to comment.