CodeCommunity commited on
Commit
5258830
·
verified ·
1 Parent(s): 045c848

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +23 -1
app/main.py CHANGED
@@ -61,7 +61,29 @@ def calculate_repo_health(total_vulns: int, avg_maint: float) -> int:
61
  return int(max(10, min(100, base_score - penalty)))
62
 
63
  def sync_review_worker(file_list: List[FileRequest]):
64
- return reviewer.service.review_batch_code(file_list)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  def parse_tree_to_list(raw_tree: str):
67
  """Parses text tree into JSON objects for Compose LazyColumn"""
 
61
  return int(max(10, min(100, base_score - penalty)))
62
 
63
  def sync_review_worker(file_list: List[FileRequest]):
64
+ # 1. Convert Pydantic models to dicts (Works for both Pydantic V1 & V2)
65
+ payload = []
66
+ for item in file_list:
67
+ if hasattr(item, "model_dump"):
68
+ payload.append(item.model_dump()) # Pydantic v2
69
+ else:
70
+ payload.append(item.dict()) # Pydantic v1
71
+
72
+ # 2. Add debug logs to verify content exists before calling service
73
+ logger.info(f"--- [DEBUG] Processing {len(payload)} files for code review ---")
74
+ for file_dict in payload:
75
+ name = file_dict.get("fileName", "Unknown")
76
+ content_len = len(file_dict.get("content") or "")
77
+ logger.info(f"File: {name} | Content length: {content_len} chars")
78
+
79
+ # 3. Call your review service with converted dicts
80
+ try:
81
+ results = reviewer.service.review_batch_code(payload)
82
+ logger.info(f"--- [DEBUG] Reviewer Output: {results} ---")
83
+ return results
84
+ except Exception as e:
85
+ logger.error(f"--- [ERROR] Exception during review processing: {e} ---", exc_info=True)
86
+ raise e
87
 
88
  def parse_tree_to_list(raw_tree: str):
89
  """Parses text tree into JSON objects for Compose LazyColumn"""