From 03c3cd7929d1239ee282dfa4491e736dd0cd1afd Mon Sep 17 00:00:00 2001 From: Joshua Date: Sat, 16 Mar 2024 17:23:42 +0800 Subject: [PATCH] refactor: rename parameter --- backend/src/server/handlers.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/server/handlers.go b/backend/src/server/handlers.go index 5ee360c0..e8289bdf 100644 --- a/backend/src/server/handlers.go +++ b/backend/src/server/handlers.go @@ -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 { @@ -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)) @@ -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))