Skip to content

Commit

Permalink
Merge pull request #59 from onesteinbv/16.0-membership_activity_gitla…
Browse files Browse the repository at this point in the history
…b-updates

[UPD] membership_activity_gitlab:Added a second to since date for gitlab activities
  • Loading branch information
ByteMeAsap authored Jul 25, 2024
2 parents 84d9b37 + e8250ac commit fa81c14
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion membership_activity_gitlab/models/project_project.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime, timezone

import dateutil

from dateutil.relativedelta import relativedelta
from odoo import api, fields, models


Expand All @@ -28,6 +28,9 @@ def get_gitlab_commits(self):
since = project.get_last_membership_activity_date_by_type(
"membership_activity_cde.commit"
)
# Adding a second to avoid duplicate activities as gitlab considers
# activities on the since date as well
since += relativedelta(seconds=1)
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
project.with_delay(max_retries=0).get_gitlab_commits_iterated(
Expand Down Expand Up @@ -70,6 +73,9 @@ def get_gitlab_merge_requests(self):
since = project.get_last_membership_activity_date_by_type(
"membership_activity_cde.pr"
)
# Adding a second to avoid duplicate activities as gitlab considers
# activities on the since date as well
since += relativedelta(seconds=1)
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
project.with_delay(max_retries=0).get_gitlab_merge_requests_iterated(
Expand Down Expand Up @@ -112,6 +118,9 @@ def get_gitlab_issues(self):
since = project.get_last_membership_activity_date_by_type(
"membership_activity_cde.issue"
)
# Adding a second to avoid duplicate activities as gitlab considers
# activities on the since date as well
since += relativedelta(seconds=1)
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
project.with_delay(max_retries=0).get_gitlab_issues_iterated(
Expand Down Expand Up @@ -154,6 +163,9 @@ def get_gitlab_notes(self):
since = project.get_last_membership_activity_date_by_type(
"membership_activity_cde.comment"
)
# Adding a second to avoid duplicate activities as gitlab considers
# activities on the since date as well
since += relativedelta(seconds=1)
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
project.with_delay(max_retries=0).get_gitlab_notes_iterated(
Expand Down Expand Up @@ -200,6 +212,9 @@ def get_gitlab_approvals(self):
since = project.get_last_membership_activity_date_by_type(
"membership_activity_cde.review"
)
# Adding a second to avoid duplicate activities as gitlab considers
# activities on the since date as well
since += relativedelta(seconds=1)
# Because pagination excludes X-Total header if it returns more than 10000 records we do it this way
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
project.with_delay(max_retries=0).get_gitlab_approvals_iterated(
Expand Down

0 comments on commit fa81c14

Please sign in to comment.