Merge pull request #44 from navi-ppl/TP-5555/log-remove

Tp 5555/log remove
This commit is contained in:
Aman Singh
2024-11-18 14:54:18 +05:30
committed by GitHub

View File

@@ -61,16 +61,16 @@ func (s *SourceMapService) GetSourceMapUploadUrl(ctx *gin.Context) {
return return
} }
// save state in database // save state in database
result := *s.dbClient.Create(&db.SourceMap{ //result := *s.dbClient.Create(&db.SourceMap{
ProjectReferenceId: projectId, // ProjectReferenceId: projectId,
ReleaseReferenceId: releaseId, // ReleaseReferenceId: releaseId,
FileName: fileName, // FileName: fileName,
State: "IN_PROGRESS", // State: "IN_PROGRESS",
}) //})
if result.Error != nil { //if result.Error != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error(), "message": "Failed to source map"}) // ctx.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error(), "message": "Failed to source map"})
return // return
} //}
ctx.JSON(http.StatusOK, gin.H{ ctx.JSON(http.StatusOK, gin.H{
"url": request.URL, "url": request.URL,
}) })
@@ -79,27 +79,27 @@ func (s *SourceMapService) GetSourceMapUploadUrl(ctx *gin.Context) {
} }
func (s *SourceMapService) SourceMapUploadAck(c *gin.Context) { func (s *SourceMapService) SourceMapUploadAck(c *gin.Context) {
var sourceMapAckBody SourceMapAckBody //var sourceMapAckBody SourceMapAckBody
if err := c.BindJSON(&sourceMapAckBody); err != nil { //if err := c.BindJSON(&sourceMapAckBody); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) // c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return // return
} //}
//
//find the record to update ack ////find the record to update ack
var existingSourceMap db.SourceMap //var existingSourceMap db.SourceMap
existingRecordError := s.dbClient.First(&existingSourceMap, "project_reference_id = ? and release_reference_id= ? and file_name = ?", sourceMapAckBody.ProjectReferenceId, sourceMapAckBody.ReleaseId, sourceMapAckBody.FileName).Error //existingRecordError := s.dbClient.First(&existingSourceMap, "project_reference_id = ? and release_reference_id= ? and file_name = ?", sourceMapAckBody.ProjectReferenceId, sourceMapAckBody.ReleaseId, sourceMapAckBody.FileName).Error
if existingRecordError != nil { //if existingRecordError != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": existingRecordError.Error()}) // c.JSON(http.StatusBadRequest, gin.H{"error": existingRecordError.Error()})
return // return
} //}
//
existingSourceMap.State = "DONE" //existingSourceMap.State = "DONE"
//
err := s.dbClient.Save(&existingSourceMap).Error //err := s.dbClient.Save(&existingSourceMap).Error
if err != nil { //if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) // c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return // return
} //}
c.JSON(http.StatusOK, gin.H{"status": "Source map stored successfully"}) c.JSON(http.StatusOK, gin.H{"status": "Source map stored successfully"})
} }