diff --git a/.claude/skills/week_report_gen_from_json/generate_report.py b/.claude/skills/week_report_gen_from_json/generate_report.py index 1c7885b..c0b02ba 100644 --- a/.claude/skills/week_report_gen_from_json/generate_report.py +++ b/.claude/skills/week_report_gen_from_json/generate_report.py @@ -240,11 +240,28 @@ def extract_report_data_from_json(json_data, user_manager=None): last_project = node['name'] # Keep updating to get the last project last_project_index = level_index - # Apply priority logic + # Apply priority logic and extract completion info + completion = None + work_package_node = None + if first_work_package: sub_project_name = first_work_package # Highest priority: first work_package + # Find the work package node to extract completion + for node in path_to_leaf[1:-1]: + if node['type'] == 'work_package' and node['name'] == first_work_package: + work_package_node = node + break elif last_project: sub_project_name = last_project # Second priority: last project + + # Extract completion from work package if available + if work_package_node and 'completion' in work_package_node: + completion = work_package_node['completion'] + + # If C column is empty or "-", try to get completion from leaf work package (E column) + if (sub_project_name == "-" or not sub_project_name) and leaf_node.get('completion'): + completion = leaf_node['completion'] + # Task name (E column) - leaf work package name task_name = leaf_node['name'] @@ -258,7 +275,7 @@ def extract_report_data_from_json(json_data, user_manager=None): report_data.append({ '專案名稱': project_name, '子項目名稱': sub_project_name, - '進度': None, # User should fill this in + '進度': completion, # Use work package completion if available '本周主要進展': progress_text, '參與人員': participant, '工時': time_entry['hours'], @@ -301,7 +318,7 @@ def format_for_weekly_report(json_data, user_manager=None): grouped_entries[group_key] = { '專案名稱': entry['專案名稱'], '子項目名稱': entry['子項目名稱'], - '進度': None, + '進度': entry['進度'], # Use completion from the first entry in the group '本周主要進展': [entry['本周主要進展'].split('\n')[0]], # Task name '參與人員': entry['參與人員'], '工時': 0, @@ -311,6 +328,10 @@ def format_for_weekly_report(json_data, user_manager=None): 'comments': [] } + # Update completion if the current entry has completion info and grouped entry doesn't + if entry['進度'] is not None and grouped_entries[group_key]['進度'] is None: + grouped_entries[group_key]['進度'] = entry['進度'] + # Aggregate hours grouped_entries[group_key]['工時'] += entry['工時'] diff --git a/README.md b/README.md index 8a53727..26044d2 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,18 @@ Fetches and displays time entries grouped by work packages for specified date ra ### 🚀 Week Report Generator from JSON (`week_report_gen_from_json`) -**New Enhanced Version**: Automatically generates weekly project reports directly from OpenProject API data via JSON format. Features intelligent cell merging, hierarchical project structure recognition, and streamlined workflow. +**New Enhanced Version**: Automatically generates weekly project reports directly from OpenProject API data via JSON format. Features intelligent cell merging, hierarchical project structure recognition, automatic progress tracking, and streamlined workflow. + +**Progress Auto-Fill Logic:** +- 🔍 **When C column (子項目名稱) contains work_package**: Automatically fills D column (進度) with work package completion percentage +- 📋 **When C column is empty or "-"**: Automatically fills D column with E column work item completion percentage +- ⚙️ **Smart Integration**: Seamlessly integrates with `week_work_package_log` completion tracking system **Key Advantages:** - 🔄 **Direct API Integration**: No manual Excel export required - 🎯 **Smart Cell Merging**: Automatic B/C/D column merging for cleaner presentation - 📊 **Hierarchical Structure**: Proper project → sub-project → task organization +- 📈 **Automatic Progress Tracking**: Auto-fills D column (進度) with work package completion percentages - ⚡ **Automated Workflow**: From data fetch to formatted report in one command - 🎨 **Professional Layout**: Enhanced visual grouping and formatting