forked from Zhubei_iXD/report_skill_expm
feat: enhance report data extraction and comment handling in week report generator and logger
This commit is contained in:
parent
a3da684e9d
commit
0ff400c97c
|
|
@ -223,21 +223,35 @@ def extract_report_data_from_json(json_data, user_manager=None):
|
||||||
project_name = path_to_leaf[0]['name'] # First element is always the project
|
project_name = path_to_leaf[0]['name'] # First element is always the project
|
||||||
|
|
||||||
# Determine sub-project name (C column)
|
# Determine sub-project name (C column)
|
||||||
|
# Structure: project_head -> project_1-1 -> ... -> project_1-1-3-2 -> work_package_1 -> work_package_1-1 -> ... -> work_package_end -> leaf
|
||||||
|
# Priority: 1) First work_package (highest level), 2) Last project (lowest level), 3) "-"
|
||||||
sub_project_name = "-"
|
sub_project_name = "-"
|
||||||
if len(path_to_leaf) > 2: # project -> work_package -> ... -> leaf
|
first_work_package = None
|
||||||
# Find the highest level work_package (first work_package in path)
|
first_work_package_index = None
|
||||||
for node in path_to_leaf[1:]: # Skip project node
|
last_project = None
|
||||||
if node['type'] == 'work_package':
|
last_project_index = None
|
||||||
sub_project_name = node['name']
|
|
||||||
break
|
|
||||||
|
|
||||||
|
# Skip the first node (root project) and last node (leaf), track level indices
|
||||||
|
for level_index, node in enumerate(path_to_leaf[1:-1], start=1):
|
||||||
|
if node['type'] == 'work_package' and first_work_package is None:
|
||||||
|
first_work_package = node['name'] # Take the first work_package found
|
||||||
|
first_work_package_index = level_index
|
||||||
|
elif node['type'] == 'project':
|
||||||
|
last_project = node['name'] # Keep updating to get the last project
|
||||||
|
last_project_index = level_index
|
||||||
|
|
||||||
|
# Apply priority logic
|
||||||
|
if first_work_package:
|
||||||
|
sub_project_name = first_work_package # Highest priority: first work_package
|
||||||
|
elif last_project:
|
||||||
|
sub_project_name = last_project # Second priority: last project
|
||||||
# Task name (E column) - leaf work package name
|
# Task name (E column) - leaf work package name
|
||||||
task_name = leaf_node['name']
|
task_name = leaf_node['name']
|
||||||
|
|
||||||
# Format progress text with comments
|
# Format progress text with comments
|
||||||
progress_parts = [task_name]
|
progress_parts = [task_name]
|
||||||
if time_entry.get('comment') and time_entry['comment'].strip():
|
if time_entry.get('comment') and time_entry['comment'].strip():
|
||||||
progress_parts.append(time_entry['comment'].strip())
|
progress_parts.append(f" - {time_entry['comment'].strip()}")
|
||||||
|
|
||||||
progress_text = '\n'.join(progress_parts)
|
progress_text = '\n'.join(progress_parts)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,11 @@ class WeekWorkPackageLogger:
|
||||||
# Extract basic information
|
# Extract basic information
|
||||||
spent_on = entry.get('spentOn', 'Unknown')
|
spent_on = entry.get('spentOn', 'Unknown')
|
||||||
comment_raw = entry.get('comment', '')
|
comment_raw = entry.get('comment', '')
|
||||||
comment = comment_raw.strip() if isinstance(comment_raw, str) else ''
|
# Extract raw comment from comment object structure
|
||||||
|
if isinstance(comment_raw, dict):
|
||||||
|
comment = comment_raw.get('raw', '').strip()
|
||||||
|
else:
|
||||||
|
comment = '' if comment_raw is None else str(comment_raw).strip()
|
||||||
hours_str = entry.get('hours', 'PT0H')
|
hours_str = entry.get('hours', 'PT0H')
|
||||||
hours = self._parse_duration(hours_str)
|
hours = self._parse_duration(hours_str)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue