Skip to content

Commit fa81c14

Browse files
authored
Merge pull request #59 from onesteinbv/16.0-membership_activity_gitlab-updates
[UPD] membership_activity_gitlab:Added a second to since date for gitlab activities
2 parents 84d9b37 + e8250ac commit fa81c14

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

membership_activity_gitlab/models/project_project.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime, timezone
22

33
import dateutil
4-
4+
from dateutil.relativedelta import relativedelta
55
from odoo import api, fields, models
66

77

@@ -28,6 +28,9 @@ def get_gitlab_commits(self):
2828
since = project.get_last_membership_activity_date_by_type(
2929
"membership_activity_cde.commit"
3030
)
31+
# Adding a second to avoid duplicate activities as gitlab considers
32+
# activities on the since date as well
33+
since += relativedelta(seconds=1)
3134
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
3235
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
3336
project.with_delay(max_retries=0).get_gitlab_commits_iterated(
@@ -70,6 +73,9 @@ def get_gitlab_merge_requests(self):
7073
since = project.get_last_membership_activity_date_by_type(
7174
"membership_activity_cde.pr"
7275
)
76+
# Adding a second to avoid duplicate activities as gitlab considers
77+
# activities on the since date as well
78+
since += relativedelta(seconds=1)
7379
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
7480
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
7581
project.with_delay(max_retries=0).get_gitlab_merge_requests_iterated(
@@ -112,6 +118,9 @@ def get_gitlab_issues(self):
112118
since = project.get_last_membership_activity_date_by_type(
113119
"membership_activity_cde.issue"
114120
)
121+
# Adding a second to avoid duplicate activities as gitlab considers
122+
# activities on the since date as well
123+
since += relativedelta(seconds=1)
115124
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
116125
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
117126
project.with_delay(max_retries=0).get_gitlab_issues_iterated(
@@ -154,6 +163,9 @@ def get_gitlab_notes(self):
154163
since = project.get_last_membership_activity_date_by_type(
155164
"membership_activity_cde.comment"
156165
)
166+
# Adding a second to avoid duplicate activities as gitlab considers
167+
# activities on the since date as well
168+
since += relativedelta(seconds=1)
157169
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
158170
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
159171
project.with_delay(max_retries=0).get_gitlab_notes_iterated(
@@ -200,6 +212,9 @@ def get_gitlab_approvals(self):
200212
since = project.get_last_membership_activity_date_by_type(
201213
"membership_activity_cde.review"
202214
)
215+
# Adding a second to avoid duplicate activities as gitlab considers
216+
# activities on the since date as well
217+
since += relativedelta(seconds=1)
203218
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
204219
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
205220
project.with_delay(max_retries=0).get_gitlab_approvals_iterated(

0 commit comments

Comments
 (0)