Germano Cavalcante commited on
Commit
758667a
·
1 Parent(s): c6cf6b5

Attempt to fix 'HTTP Error 403: Forbidden'

Browse files
routers/tool_find_related.py CHANGED
@@ -15,7 +15,7 @@ from fastapi.responses import PlainTextResponse
15
  try:
16
  from .rag import EMBEDDING_CTX
17
  from .utils_gitea import gitea_fetch_issues, gitea_json_issue_get, gitea_issues_body_updated_at_get
18
- except ModuleNotFoundError:
19
  from rag import EMBEDDING_CTX
20
  from utils_gitea import gitea_fetch_issues, gitea_json_issue_get, gitea_issues_body_updated_at_get
21
 
@@ -174,7 +174,7 @@ class _Data(dict):
174
 
175
  self._data_ensure_size(repo, int(issues[0]['number']))
176
 
177
- updated_at = gitea_issues_body_updated_at_get(issues)
178
  issues_to_embed = []
179
 
180
  for i, issue in enumerate(issues):
 
15
  try:
16
  from .rag import EMBEDDING_CTX
17
  from .utils_gitea import gitea_fetch_issues, gitea_json_issue_get, gitea_issues_body_updated_at_get
18
+ except (ModuleNotFoundError, ImportError):
19
  from rag import EMBEDDING_CTX
20
  from utils_gitea import gitea_fetch_issues, gitea_json_issue_get, gitea_issues_body_updated_at_get
21
 
 
174
 
175
  self._data_ensure_size(repo, int(issues[0]['number']))
176
 
177
+ updated_at = None #gitea_issues_body_updated_at_get(issues)
178
  issues_to_embed = []
179
 
180
  for i, issue in enumerate(issues):
routers/utils_gitea.py CHANGED
@@ -94,13 +94,17 @@ def gitea_issues_body_updated_at_get(issues, verbose=True):
94
  if verbose:
95
  print(f"Fetched issue #{number}")
96
 
 
 
 
 
97
  json_data = url_json_get(
98
  f"https://projects.blender.org/blender/blender/issues/{number}/content-history/list")
99
- # Verify that the response contains the expected data before trying to access it
100
  if json_data and json_data['results']:
101
  return json_data['results'][0]['name'].split('datetime="')[1].split('"')[0]
102
  else:
103
- return issue['created_at']
104
 
105
  with ThreadPoolExecutor() as executor:
106
  futures = [executor.submit(fetch_issue, issue) for issue in issues]
 
94
  if verbose:
95
  print(f"Fetched issue #{number}")
96
 
97
+ # Changes to the issue description are not reflected in `issue['updated_at']`.
98
+ # To retrieve the actual update datetime for the issue body, we need to use a different API endpoint.
99
+ # Note: Requests to this endpoint may trigger "HTTP Error 403: Forbidden"
100
+ # due to Blender's anti-scraping measures.
101
  json_data = url_json_get(
102
  f"https://projects.blender.org/blender/blender/issues/{number}/content-history/list")
103
+
104
  if json_data and json_data['results']:
105
  return json_data['results'][0]['name'].split('datetime="')[1].split('"')[0]
106
  else:
107
+ return issue['updated_at']
108
 
109
  with ThreadPoolExecutor() as executor:
110
  futures = [executor.submit(fetch_issue, issue) for issue in issues]