Merge pull request #49 from navi-ppl/TP-5555/fix-project-update

TP-5555 | fix project reference id
This commit is contained in:
Varnit Goyal
2024-12-03 07:24:40 +05:30
committed by GitHub

View File

@@ -29,12 +29,14 @@ type ProjectBody struct {
Team string `json:"team" binding:"required"` Team string `json:"team" binding:"required"`
Icon string `json:"icon"` Icon string `json:"icon"`
GithubUrl string `json:"githubUrl" binding:"required"` GithubUrl string `json:"githubUrl" binding:"required"`
Account string `json:"account" binding:"required"`
} }
type UpdateProjectBody struct { type UpdateProjectBody struct {
Icon string `json:"logoUrl" binding:"required"` Icon string `json:"logoUrl" binding:"required"`
GithubUrl string `json:"githubUrl" binding:"required"` GithubUrl string `json:"githubUrl" binding:"required"`
IgnorePatterns []string `json:"ignorePatterns" binding:"required"` IgnorePatterns []string `json:"ignorePatterns" binding:"required"`
Account string `json:"account" binding:"required"`
} }
func NewProjectCreator(logger *log.Logger, dbClient *gorm.DB, s3Client *aws.Actions, kafkaProducer producer.KProducer) *ProjectCreator { func NewProjectCreator(logger *log.Logger, dbClient *gorm.DB, s3Client *aws.Actions, kafkaProducer producer.KProducer) *ProjectCreator {
@@ -75,6 +77,7 @@ func (pc *ProjectCreator) CreateProject(ctx *gin.Context) {
Icon: projectBody.Icon, Icon: projectBody.Icon,
GithubUrl: projectBody.GithubUrl, GithubUrl: projectBody.GithubUrl,
Secret: hex.EncodeToString(secret), Secret: hex.EncodeToString(secret),
Account: projectBody.Account,
}) })
if result.Error != nil { if result.Error != nil {
@@ -138,10 +141,11 @@ func (pc *ProjectCreator) ProjectUpdate(c *gin.Context) {
} }
// Update the project in the database // Update the project in the database
if result := pc.dbClient.Where("id = ?", projectId).Updates(&db.Project{ if result := pc.dbClient.Where("project_reference_id = ?", projectId).Updates(&db.Project{
GithubUrl: updateProjectBody.GithubUrl, GithubUrl: updateProjectBody.GithubUrl,
Icon: updateProjectBody.Icon, Icon: updateProjectBody.Icon,
IgnorePatterns: updateProjectBody.IgnorePatterns, IgnorePatterns: updateProjectBody.IgnorePatterns,
Account: updateProjectBody.Account,
}); result.Error != nil { }); result.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error()})
return return