4 Commits

Author SHA1 Message Date
Gan, Jimmy c27cc505e1 fix: add batch processing for large conversation files
Run Tests / Backend Tests (pull_request) Failing after 5m48s
Run Tests / Frontend Tests (pull_request) Failing after 2m1s
Run Tests / Test Summary (pull_request) Failing after 15s
2026-04-12 11:33:24 +08:00
jimmy 5579deb433 Merge pull request 'Fix network mode for claude-code-tracker' (#47) from fix/tracker-network into main
Run Tests / Backend Tests (push) Failing after 4m24s
Run Tests / Frontend Tests (push) Failing after 1m33s
Run Tests / Test Summary (push) Failing after 21s
2026-04-12 08:53:39 +08:00
Gan, Jimmy 145e836342 fix: add network_mode bridge to claude-code-tracker
Run Tests / Backend Tests (pull_request) Failing after 4m22s
Run Tests / Frontend Tests (pull_request) Failing after 1m24s
Run Tests / Test Summary (pull_request) Failing after 18s
2026-04-12 08:50:20 +08:00
jimmy 728fa141ed Merge pull request 'Add Claude Code conversation tracker' (#46) from feat/claude-code-tracker into main
Run Tests / Backend Tests (push) Has been cancelled
Run Tests / Frontend Tests (push) Has been cancelled
Run Tests / Test Summary (push) Has been cancelled
Deploy Dashboard / deploy (push) Failing after 16m27s
2026-04-12 08:46:37 +08:00
3 changed files with 16 additions and 9 deletions
+9 -5
View File
@@ -52,9 +52,13 @@ async def process_file(file_path: str):
# No new lines
return 0
# Process in batches for large files (max 200 lines at a time)
batch_size = 200
end_line = min(start_line + batch_size, total_lines)
# Parse new content
logger.info(f"Processing {file_path} from line {start_line} to {total_lines}")
conversation_data = parser.parse_conversation_file(file_path, start_line)
logger.info(f"Processing {file_path} from line {start_line} to {end_line} (total: {total_lines})")
conversation_data = parser.parse_conversation_file(file_path, start_line, end_line)
if not conversation_data:
logger.warning(f"No data extracted from {file_path}")
@@ -87,10 +91,10 @@ async def process_file(file_path: str):
for tool_call in conversation_data['tool_calls']:
await db.insert_tool_call(tool_call)
# Update checkpoint
await db.update_checkpoint(file_path, total_lines, file_mtime)
# Update checkpoint (use end_line instead of total_lines for batch processing)
await db.update_checkpoint(file_path, end_line, file_mtime)
logger.info(f"Processed {len(conversation_data['messages'])} messages from {file_path}")
logger.info(f"Processed {len(conversation_data['messages'])} messages from {file_path} (batch {start_line}-{end_line}/{total_lines})")
return len(conversation_data['messages'])
except Exception as e:
+1
View File
@@ -3,6 +3,7 @@ services:
build: .
container_name: claude-code-tracker
restart: unless-stopped
network_mode: bridge
volumes:
- /volume1/docker/claude-code-tracker/data:/app/data
- /volume1/docker/claude-code-tracker/conversations:/app/conversations:ro
+6 -4
View File
@@ -6,14 +6,16 @@ from typing import Dict, List, Any, Optional
logger = logging.getLogger(__name__)
def parse_jsonl_file(file_path: str, start_line: int = 0) -> List[Dict[str, Any]]:
"""Parse JSONL file from a specific line number"""
def parse_jsonl_file(file_path: str, start_line: int = 0, end_line: int = None) -> List[Dict[str, Any]]:
"""Parse JSONL file from a specific line number to end_line (or EOF if None)"""
messages = []
try:
with open(file_path, 'r', encoding='utf-8') as f:
for i, line in enumerate(f):
if i < start_line:
continue
if end_line is not None and i >= end_line:
break
if not line.strip():
continue
try:
@@ -169,9 +171,9 @@ def calculate_conversation_stats(messages: List[Dict[str, Any]]) -> Dict[str, An
return stats
def parse_conversation_file(file_path: str, start_line: int = 0) -> Dict[str, Any]:
def parse_conversation_file(file_path: str, start_line: int = 0, end_line: int = None) -> Dict[str, Any]:
"""Parse a conversation file and extract all data"""
raw_messages = parse_jsonl_file(file_path, start_line)
raw_messages = parse_jsonl_file(file_path, start_line, end_line)
if not raw_messages:
return None