You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/12/22 01:39:26 UTC
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #4009: feat: add time filter for gitlab jobs
likyh commented on code in PR #4009:
URL: https://github.com/apache/incubator-devlake/pull/4009#discussion_r1055002248
##########
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:
ok, only finish when all items are created before `createDateAfter`.
`createDateAfter` means only accepting items created after it, So if all items reject, collect need finish.
--
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