fix: subproject not shown on final report

This commit is contained in:
insleker 2026-01-19 16:23:26 +08:00
parent a5c782e54d
commit e468848440
4 changed files with 51 additions and 13 deletions

View File

@ -16,7 +16,7 @@
}, },
{ {
"nickname": "傑 羅", "nickname": "傑 羅",
"formal_name": "羅傑", "formal_name": "羅傑",
"english_name": "Jie Luo", "english_name": "Jie Luo",
"team": "智能控制組", "team": "智能控制組",
"department": "軟體部" "department": "軟體部"

View File

@ -292,8 +292,17 @@ class ProjectManager:
return None return None
parent = self.hierarchy[project_id]['parent'] parent = self.hierarchy[project_id]['parent']
if parent: if parent and isinstance(parent, dict):
return parent.get('identifier') if isinstance(parent, dict) else parent parent_numeric_id = str(parent.get('id'))
if parent_numeric_id and parent_numeric_id != 'None':
# Find the project identifier for this numeric ID
for proj_id, proj_data in self.projects.items():
if str(proj_data['id']) == parent_numeric_id:
return proj_id
elif parent:
# Handle string parent (legacy format)
return parent
return None return None
def get_full_path(self, project_id: str) -> List[str]: def get_full_path(self, project_id: str) -> List[str]:
@ -383,6 +392,27 @@ class ProjectManager:
names = [self.hierarchy.get(p, {}).get('name', p) for p in path] names = [self.hierarchy.get(p, {}).get('name', p) for p in path]
return ' > '.join(names) return ' > '.join(names)
def find_project_by_name(self, name: str) -> Optional[str]:
"""
Find project identifier by exact name match (case-insensitive).
Args:
name: Project name to search for
Returns:
Project identifier or None if not found
"""
if not self.projects:
self.fetch_projects()
name_lower = name.lower().strip()
for project_id, project in self.projects.items():
if project['name'].lower().strip() == name_lower:
return project_id
return None
def search_projects(self, query: str) -> Dict: def search_projects(self, query: str) -> Dict:
""" """
Search projects by name or identifier. Search projects by name or identifier.

View File

@ -240,8 +240,10 @@ def format_for_weekly_report(summary_df, user_manager=None, project_manager=None
sub_project_name = None sub_project_name = None
if project_manager: if project_manager:
# Normalize project name for lookup (lowercase, replace spaces with hyphens) # Try to find the project by exact name match
project_id = project.lower().replace(' ', '-') project_id = project_manager.find_project_by_name(project)
if project_id:
parent_id = project_manager.get_parent(project_id) parent_id = project_manager.get_parent(project_id)
if parent_id: if parent_id:
@ -251,6 +253,9 @@ def format_for_weekly_report(summary_df, user_manager=None, project_manager=None
parent_project = parent_info['name'] parent_project = parent_info['name']
sub_project_name = project sub_project_name = project
project_name = parent_project project_name = parent_project
else:
# Project not found in hierarchy, log for debugging
pass
report_data.append({ report_data.append({
'專案名稱': project_name, '專案名稱': project_name,

3
AGENTS.md Normal file
View File

@ -0,0 +1,3 @@
# AGENTS.md
always read `README.md` for instructions on how to run the code first.