warren830 commented on code in PR #4371:
URL: 
https://github.com/apache/incubator-devlake/pull/4371#discussion_r1102343909


##########
backend/plugins/sonarqube/tasks/projects_extractor.go:
##########
@@ -28,13 +28,39 @@ import (
 var _ plugin.SubTaskEntryPoint = ExtractProjects
 
 func ExtractProjects(taskCtx plugin.SubTaskContext) errors.Error {
-       rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, 
RAW_PROJECTS_TABLE)
+       // As we need to assign data.LastAnalysisDate, we can not use 
CreateRawDataSubTaskArgs
+       data := taskCtx.GetData().(*SonarqubeTaskData)
+       var params = SonarqubeApiParams{
+               ConnectionId: data.Options.ConnectionId,
+               ProjectKey:   data.Options.ProjectKey,
+       }
+       rawDataSubTaskArgs := &helper.RawDataSubTaskArgs{
+               Ctx:    taskCtx,
+               Params: params,
+               Table:  RAW_PROJECTS_TABLE,
+       }
        extractor, err := helper.NewApiExtractor(helper.ApiExtractorArgs{
                RawDataSubTaskArgs: *rawDataSubTaskArgs,
                Extract: func(resData *helper.RawData) ([]interface{}, 
errors.Error) {
-                       body := &models.SonarqubeProject{}
-                       err := errors.Convert(json.Unmarshal(resData.Data, 
body))
-                       body.ConnectionId = data.Options.ConnectionId
+                       var res struct {
+                               ProjectKey       string              
`json:"key"`
+                               Name             string              
`json:"name"`
+                               Qualifier        string              
`json:"qualifier"`
+                               Visibility       string              
`json:"visibility"`
+                               LastAnalysisDate *helper.Iso8601Time 
`json:"lastAnalysisDate"`
+                               Revision         string              
`json:"revision"`
+                       }
+                       err := errors.Convert(json.Unmarshal(resData.Data, 
&res))
+                       body := &models.SonarqubeProject{
+                               ConnectionId:     data.Options.ConnectionId,
+                               ProjectKey:       res.ProjectKey,
+                               Name:             res.Name,
+                               Qualifier:        res.Qualifier,
+                               Visibility:       res.Visibility,
+                               LastAnalysisDate: res.LastAnalysisDate,
+                               Revision:         res.Revision,
+                       }
+                       data.LastAnalysisDate = 
body.LastAnalysisDate.ToNullableTime()

Review Comment:
   What is this? I remember I already changed this



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to