klesh commented on code in PR #4009:
URL: 
https://github.com/apache/incubator-devlake/pull/4009#discussion_r1054995864


##########
plugins/gitlab/tasks/shared.go:
##########
@@ -74,6 +75,38 @@ func GetRawMessageFromResponse(res *http.Response) 
([]json.RawMessage, errors.Er
        return rawMessages, nil
 }
 
+func GetRawMessageCreatedAtAfter(createDateAfter *time.Time) func(res 
*http.Response) ([]json.RawMessage, errors.Error) {
+       type ApiModel struct {
+               CreatedAt *helper.Iso8601Time `json:"created_at"`
+       }
+
+       return func(res *http.Response) ([]json.RawMessage, errors.Error) {
+               rawMessages, err := GetRawMessageFromResponse(res)
+               if err != nil {
+                       return nil, errors.Default.Wrap(err, fmt.Sprintf("error 
reading response from %s", res.Request.URL.String()))
+               }
+               isFinish := true
+               filterRawMessages := []json.RawMessage{}
+               for _, rawMessage := range rawMessages {
+                       apiModel := &ApiModel{}
+                       err = errors.Convert(json.Unmarshal(rawMessage, 
apiModel))
+                       if err != nil {
+                               return nil, err
+                       }
+                       if createDateAfter == nil || 
createDateAfter.Before(apiModel.CreatedAt.ToTime()) {
+                               // only finish when all item before 
`createDateAfter`

Review Comment:
   The comment is not correct. It should be "all **items created after**"



-- 
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