From 99a73371068d7ff1c2fe396ec26c81d5dcc88eb3 Mon Sep 17 00:00:00 2001 From: P Nitish Date: Thu, 24 Apr 2025 21:18:59 +0530 Subject: [PATCH 1/3] fixes bounties/payouts --- website/views/organization.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/website/views/organization.py b/website/views/organization.py index cfe9aa3bdb..53c85da243 100644 --- a/website/views/organization.py +++ b/website/views/organization.py @@ -549,8 +549,6 @@ def github_issues_with_bounties(self, label, issue_state="open", page=1, per_pag for issue in issues: related_prs = [] - - # Only include issues, not PRs in the response if issue.get("pull_request") is None: formatted_issue = { "id": issue.get("id"), @@ -2729,7 +2727,6 @@ def github_issues_with_bounties(self, label="$5", issue_state="closed", page=1, encoded_label = label.replace("$", "%24") query_params = f"repo:OWASP-BLT/BLT+is:issue+state:{issue_state}+label:{encoded_label}" url = f"https://api.github.com/search/issues?q={query_params}&page={page}&per_page={per_page}" - headers = {} if settings.GITHUB_TOKEN: headers["Authorization"] = f"token {settings.GITHUB_TOKEN}" @@ -2739,18 +2736,18 @@ def github_issues_with_bounties(self, label="$5", issue_state="closed", page=1, if response.status_code == 200: data = response.json() issues = data.get("items", []) - + total_count = data.get("total_count", 0) # Cache the results for 30 minutes cache.set(cache_key, issues, 60 * 30) - return issues + return issues, total_count else: # Log the error response from GitHub logger.error(f"GitHub API error: {response.status_code} - {response.text[:200]}") - return [] + return [], 0 except Exception as e: logger.error(f"Error fetching GitHub issues: {str(e)}") - return [] + return [], 0 def post(self, request, *args, **kwargs): """Handle POST requests for refreshing issues or processing payments""" @@ -2769,6 +2766,20 @@ def post(self, request, *args, **kwargs): try: # Import required models from website.models import GitHubIssue, Repo + page = 1 + per_page = 100 + all_issues = [] + total_count = None + while True: + issues, api_total_count = self.github_issues_with_bounties("$5", "closed", page, per_page) + if total_count is None and api_total_count is not None: + total_count = api_total_count + if not issues: + break + all_issues.extend(issues) + if len(issues) < per_page or len(all_issues) >= total_count: + break + page += 1 issues = self.github_issues_with_bounties("$5", "closed", per_page=100) count = 0 From 344c591db017774b79d85d93aae10486a9503dad Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Fri, 2 May 2025 20:33:57 -0400 Subject: [PATCH 2/3] Update website/views/organization.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- website/views/organization.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/views/organization.py b/website/views/organization.py index 53c85da243..e608a33192 100644 --- a/website/views/organization.py +++ b/website/views/organization.py @@ -2781,7 +2781,8 @@ def post(self, request, *args, **kwargs): break page += 1 - issues = self.github_issues_with_bounties("$5", "closed", per_page=100) + issues = all_issues + count = 0 count = 0 for issue_data in issues: From 572906ba013aca509aef7d978bad5360d7b9274a Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Fri, 2 May 2025 20:54:16 -0400 Subject: [PATCH 3/3] Update organization.py --- website/views/organization.py | 1 + 1 file changed, 1 insertion(+) diff --git a/website/views/organization.py b/website/views/organization.py index e608a33192..2334d4ceb9 100644 --- a/website/views/organization.py +++ b/website/views/organization.py @@ -2766,6 +2766,7 @@ def post(self, request, *args, **kwargs): try: # Import required models from website.models import GitHubIssue, Repo + page = 1 per_page = 100 all_issues = []