Skip to content

Commit

Permalink
fixes for crash
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Oct 30, 2024
1 parent 4839843 commit 500a2fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,20 @@ def _generate_reports(self, processed_data: Dict[str, Any]) -> None:

# Save raw data
self._save_report(processed_data, 'github_portfolio.json', is_json=True)

def _save_report(self, content: Any, filename: str, is_json: bool = False) -> None:
"""Save report to file."""
def json_serial(obj):
"""JSON serializer for objects not serializable by default json code"""
if isinstance(obj, datetime):
return obj.isoformat()
raise TypeError(f"Type {type(obj)} not serializable")

try:
mode = 'w' if not is_json else 'w'
with open(filename, mode, encoding='utf-8') as f:
if is_json:
import json
json.dump(content, f, indent=2, ensure_ascii=False)
json.dump(content, f, indent=2, default=json_serial)
else:
f.write(content)

Expand All @@ -104,7 +109,6 @@ def _save_report(self, content: Any, filename: str, is_json: bool = False) -> No
except Exception as e:
self.logger.error(f"Error saving report {filename}: {e}")
raise

def cleanup(self) -> None:
"""Cleanup resources and temporary files."""
try:
Expand Down
4 changes: 2 additions & 2 deletions src/generators/markdown_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ def _generate_activity_chart(self, commit_frequency: Dict) -> str:

for point in data_points:
if point['total'] >= threshold:
row.append(self.CHART_CHARS['block_full'])
row.append(CHART_CHARS['block_full'])
else:
row.append(self.CHART_CHARS['block_empty'])
row.append(CHART_CHARS['block_empty'])

chart.append(''.join(row))

Expand Down

0 comments on commit 500a2fc

Please sign in to comment.