Skip to content

Commit

Permalink
refactor: rename parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtyf committed Mar 16, 2024
1 parent aa48400 commit 03c3cd7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/src/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func handleGetServiceRequest(mongoClient *mongo.Client, psqlClient *sql.DB) http
})
}

func handleCreateServiceRequest(client *mongo.Client, psqlClient *sql.DB) http.Handler {
func handleCreateServiceRequest(mongoClient *mongo.Client, psqlClient *sql.DB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
srm, err := decode[models.ServiceRequestModel](r)
if err != nil {
Expand All @@ -99,7 +99,7 @@ func handleCreateServiceRequest(client *mongo.Client, psqlClient *sql.DB) http.H
return
}

pipeline, err := database.NewPipeline(client).GetById(srm.PipelineId)
pipeline, err := database.NewPipeline(mongoClient).GetById(srm.PipelineId)
if errors.Is(err, mongo.ErrNoDocuments) {
logger.Error("[CreateServiceRequest] Invalid pipeline id, no matching pipeline found", map[string]interface{}{"pipelineId": srm.PipelineId})
encode(w, r, http.StatusBadRequest, newHandlerError(ErrInvalidPipelineId, http.StatusBadRequest))
Expand All @@ -114,7 +114,7 @@ func handleCreateServiceRequest(client *mongo.Client, psqlClient *sql.DB) http.H
srm.LastUpdated = time.Now()
srm.Status = models.NotStarted

res, err := database.NewServiceRequest(client).Create(&srm)
res, err := database.NewServiceRequest(mongoClient).Create(&srm)
if err != nil {
logger.Error("[CreateServiceRequest] Error creating service request", map[string]interface{}{"err": err})
encode(w, r, http.StatusInternalServerError, newHandlerError(ErrInternalServerError, http.StatusInternalServerError))
Expand Down

0 comments on commit 03c3cd7

Please sign in to comment.