You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "likyh (via GitHub)" <gi...@apache.org> on 2023/02/21 13:39:57 UTC

[GitHub] [incubator-devlake] likyh commented on a diff in pull request #4477: fix(sonarqube): fix data loss

likyh commented on code in PR #4477:
URL: https://github.com/apache/incubator-devlake/pull/4477#discussion_r1113073427


##########
backend/plugins/sonarqube/impl/impl.go:
##########
@@ -123,30 +123,22 @@ func (p Sonarqube) PrepareTaskData(taskCtx plugin.TaskContext, options map[strin
 		Options:   op,
 		ApiClient: apiClient,
 	}
-	if op.ProjectKey != "" {
-		var scope *models.SonarqubeProject
-		var apiProject *tasks.SonarqubeApiProject
-		// support v100 & advance mode
-		// If we still cannot find the record in db, we have to request from remote server and save it to db
-		db := taskCtx.GetDal()
-		err = db.First(&scope, dal.Where("connection_id = ? AND project_key = ?", op.ConnectionId, op.ProjectKey))
-		if err != nil && db.IsErrorNotFound(err) {
-			apiProject, err = api.GetApiProject(op.ProjectKey, apiClient)
-			if err != nil {
-				return nil, err
-			}
-			logger.Debug(fmt.Sprintf("Current project: %s", apiProject.ProjectKey))
-			scope = tasks.ConvertProject(apiProject)
-			scope.ConnectionId = op.ConnectionId
-			err = taskCtx.GetDal().CreateIfNotExist(&scope)
-			if err != nil {
-				return nil, err
-			}
-		}
-		if err != nil {
-			return nil, errors.Default.Wrap(err, fmt.Sprintf("fail to find project: %s", op.ProjectKey))
-		}
+	// even we have project in _tool_sonaqube_projects, we still need to collect project to update LastAnalysisDate

Review Comment:
   why? what column updated?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org