1
1
from datetime import datetime , timezone
2
2
3
3
import dateutil
4
-
4
+ from dateutil . relativedelta import relativedelta
5
5
from odoo import api , fields , models
6
6
7
7
@@ -28,6 +28,9 @@ def get_gitlab_commits(self):
28
28
since = project .get_last_membership_activity_date_by_type (
29
29
"membership_activity_cde.commit"
30
30
)
31
+ # Adding a second to avoid duplicate activities as gitlab considers
32
+ # activities on the since date as well
33
+ since += relativedelta (seconds = 1 )
31
34
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
32
35
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
33
36
project .with_delay (max_retries = 0 ).get_gitlab_commits_iterated (
@@ -70,6 +73,9 @@ def get_gitlab_merge_requests(self):
70
73
since = project .get_last_membership_activity_date_by_type (
71
74
"membership_activity_cde.pr"
72
75
)
76
+ # Adding a second to avoid duplicate activities as gitlab considers
77
+ # activities on the since date as well
78
+ since += relativedelta (seconds = 1 )
73
79
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
74
80
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
75
81
project .with_delay (max_retries = 0 ).get_gitlab_merge_requests_iterated (
@@ -112,6 +118,9 @@ def get_gitlab_issues(self):
112
118
since = project .get_last_membership_activity_date_by_type (
113
119
"membership_activity_cde.issue"
114
120
)
121
+ # Adding a second to avoid duplicate activities as gitlab considers
122
+ # activities on the since date as well
123
+ since += relativedelta (seconds = 1 )
115
124
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
116
125
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
117
126
project .with_delay (max_retries = 0 ).get_gitlab_issues_iterated (
@@ -154,6 +163,9 @@ def get_gitlab_notes(self):
154
163
since = project .get_last_membership_activity_date_by_type (
155
164
"membership_activity_cde.comment"
156
165
)
166
+ # Adding a second to avoid duplicate activities as gitlab considers
167
+ # activities on the since date as well
168
+ since += relativedelta (seconds = 1 )
157
169
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
158
170
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
159
171
project .with_delay (max_retries = 0 ).get_gitlab_notes_iterated (
@@ -200,6 +212,9 @@ def get_gitlab_approvals(self):
200
212
since = project .get_last_membership_activity_date_by_type (
201
213
"membership_activity_cde.review"
202
214
)
215
+ # Adding a second to avoid duplicate activities as gitlab considers
216
+ # activities on the since date as well
217
+ since += relativedelta (seconds = 1 )
203
218
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
204
219
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
205
220
project .with_delay (max_retries = 0 ).get_gitlab_approvals_iterated (
0 commit comments