Skip to content

schedule_actual コマンドの作成#307

Open
yuji38kwmt wants to merge 5 commits intomainfrom
202604-2-0101
Open

schedule_actual コマンドの作成#307
yuji38kwmt wants to merge 5 commits intomainfrom
202604-2-0101

Conversation

@yuji38kwmt
Copy link
Copy Markdown
Collaborator

@yuji38kwmt yuji38kwmt commented Apr 28, 2026

This pull request introduces a new schedule_actual command group to the CLI, enabling users to output combined daily and weekly working hours (both scheduled and actual) for jobs, along with corresponding documentation and internal utilities. It also adds or updates several coding, testing, and documentation style guides, and makes minor configuration and policy adjustments.

The most important changes are:

New CLI Feature: Combined Schedule and Actual Working Hours

  • Added the schedule_actual command group with two subcommands:
    • list_daily: Outputs daily combined scheduled and actual working hours for a parent job. [1]], [2]], [3]], [4]])
    • list_weekly: Outputs weekly combined scheduled and actual working hours for a parent job. [1]], [2]])
  • Implemented supporting logic in annoworkcli/schedule_actual/common.py for data aggregation, date handling, and output formatting. ([annoworkcli/schedule_actual/common.pyR1-R167])

Documentation

  • Added Sphinx documentation for the new schedule_actual commands, including usage examples and argument references. [1]], [2]], [3]], [4]])

Coding, Testing, and Documentation Style Guides

Project Policy and Configuration

  • Added or updated project policies in AGENTS.md (e.g., destructive change preference, review/test steps) ([AGENTS.mdR1-R13])
  • Added .codex/config.toml with sandbox and approval policy settings ([.codex/config.tomlR1-R24])

Test Structure

These changes collectively add a major new feature for reporting on scheduled and actual working hours, ensure it is well-documented, and strengthen project conventions and configuration.

…orting

- Implemented `list_daily` and `list_weekly` commands to output daily and weekly working hours.
- Created necessary modules and functions for data processing and output formatting.
- Updated documentation to include new commands in the command reference.
- Added tests for the new functionality to ensure correctness.
Copilot AI review requested due to automatic review settings April 28, 2026 04:45
@kci-pr-agent
Copy link
Copy Markdown
Contributor

kci-pr-agent Bot commented Apr 28, 2026

Title

202604 2 0101


Description

  • schedule_actualサブコマンドを追加

  • 日次/週次の予定と実績を結合出力

  • スケジュール実績関連のテストを追加

  • CLIドキュメントを更新


Changes walkthrough 📝

Relevant files
Enhancement
__main__.py
CLIに`schedule_actual`サブコマンドを登録                                                     
+2/-0     
__init__.py
`schedule_actual`パッケージを追加                                                               
+1/-0     
common.py
データ集計用の共通ユーティリティ実装                                                                             
+167/-0 
list_daily.py
日次勤務時間取得コマンドを実装                                                                                   
+68/-0   
list_weekly.py
週次勤務時間取得コマンドを実装                                                                                   
+69/-0   
subcommand.py
サブコマンド解析を設定                                                                                           
+23/-0   
Tests
__init__.py
テスト用パッケージを作成                                                                                         
+1/-0     
test_common.py
共通集計関数のユニットテスト追加                                                                                 
+85/-0   
test_schedule_actual_command.py
CLIコマンドの統合テスト追加                                                                                   
+67/-0   
test_subcommand.py
サブコマンドパーサーのテスト追加                                                                                 
+21/-0   
Documentation
SKILL.md
CLIコマンドスタイルガイドを追加                                                                               
+39/-0   
SKILL.md
ドキュメントスタイルガイドを追加                                                                                 
+8/-0     
SKILL.md
Pythonコーディングスタイルガイドを追加                                                                     
+14/-0   
SKILL.md
テスト作成スタイルガイドを追加                                                                                   
+25/-0   
AGENTS.md
エージェント作業方針を追加                                                                                       
+13/-0   
index.rst
ドキュメントに`schedule_actual`を追加                                                           
+1/-0     
index.rst
`schedule_actual`リファレンスを作成                                                             
+26/-0   
list_daily.rst
`list_daily`ドキュメントを追加                                                                       
+49/-0   
list_weekly.rst
`list_weekly`ドキュメントを追加                                                                     
+51/-0   
Configuration changes
config.toml
Codex設定ファイルを追加                                                                                     
+24/-0   

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @kci-pr-agent
    Copy link
    Copy Markdown
    Contributor

    kci-pr-agent Bot commented Apr 28, 2026

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Range Clamping Logic

    get_daily_schedule_actual_df 内の実績/予定期間取得の条件分岐 (if actual_start_date is None or actual_end_date is None or actual_start_date <= actual_end_date) が OR になっており、
    start_date > end_date の場合でも意図せず API コールやデータ処理が走ってしまう可能性があります。AND 条件への修正を検討してください。

    actual_hours_by_date: dict[str, float] = {}
    if actual_start_date is None or actual_end_date is None or actual_start_date <= actual_end_date:
        actual_working_times = list_actual_working_time_obj.get_actual_working_times(
            parent_job_ids=[parent_job_id],
            start_date=actual_start_date,
            end_date=actual_end_date,
            user_ids=None,
            is_set_additional_info=True,
        )
    Weekly Resampling Boundary

    build_weekly_schedule_actual_dfresample("W-SUN", label="left", closed="left")
    週の範囲(日曜始まり/土曜終わり)を正しく集計できているか、端境日やタイムゾーン変化時の振る舞いを確認してください。

    df = daily_df.copy()
    df["dt_date"] = pandas.to_datetime(df["date"])
    df_weekly = df.resample("W-SUN", on="dt_date", label="left", closed="left").agg(
        {
            "assigned_working_hours": "sum",
            "actual_working_hours": "sum",
        }
    )
    df_weekly.reset_index(inplace=True)
    df_weekly.rename(columns={"dt_date": "dt_start_date"}, inplace=True)
    df_weekly["dt_end_date"] = df_weekly["dt_start_date"] + pandas.Timedelta(days=6)
    df_weekly["start_date"] = df_weekly["dt_start_date"].dt.date.apply(lambda e: e.isoformat())
    df_weekly["end_date"] = df_weekly["dt_end_date"].dt.date.apply(lambda e: e.isoformat())
    df_weekly["cumulative_working_hours"] = (df_weekly["assigned_working_hours"] + df_weekly["actual_working_hours"]).cumsum()
    return df_weekly[WEEKLY_COLUMNS]


    df = daily_df.copy()
    df["dt_date"] = pandas.to_datetime(df["date"])
    df_weekly = df.resample("W-SUN", on="dt_date", label="left", closed="left").agg(
    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: 週の集計を日曜始まり土曜終わりに合わせるため、resample の頻度を "W-SAT" に変更してください。これでテスト期待値の週開始日が正しく取得できます。 [possible issue, importance: 9]

    Suggested change
    df_weekly = df.resample("W-SUN", on="dt_date", label="left", closed="left").agg(
    df_weekly = df.resample("W-SAT", on="dt_date", label="left", closed="left").agg(

    Copy link
    Copy Markdown
    Contributor

    Copilot AI left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Pull request overview

    予定(作業計画)と実績(実績作業時間)を結合した「schedule_actual」サブコマンドを追加し、日次/週次の集計結果を出力できるようにするPRです。

    Changes:

    • annoworkcli schedule_actual list_daily|list_weekly を追加し、当日境界で「過去=実績」「未来=予定」を結合して集計・出力
    • コマンドリファレンス(Sphinx + argparse)を追加し、Command Reference の目次に掲載
    • 集計ロジックの単体テストとWebAPIアクセスのコマンドテストを追加(+ agent向け設定/ガイドを追加)

    Reviewed changes

    Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

    Show a summary per file
    File Description
    annoworkcli/main.py schedule_actual サブコマンドをトップレベルCLIに登録
    annoworkcli/schedule_actual/common.py 日次/週次の結合・集計、およびWebAPIからの取得処理を実装
    annoworkcli/schedule_actual/list_daily.py 日次出力コマンドのCLI引数定義と実行処理を追加
    annoworkcli/schedule_actual/list_weekly.py 週次出力コマンドのCLI引数定義と実行処理を追加
    annoworkcli/schedule_actual/subcommand.py schedule_actual 配下のサブコマンド登録(list_daily/list_weekly)
    annoworkcli/schedule_actual/init.py パッケージ追加
    tests/schedule_actual/test_common.py 日次/週次のDataFrame生成ロジックの単体テスト追加
    tests/schedule_actual/test_schedule_actual_command.py WebAPIアクセスを伴うE2E寄りのコマンドテスト追加
    tests/schedule_actual/test_subcommand.py argparse パーサーの配線確認テスト追加
    tests/schedule_actual/init.py テストパッケージ追加
    docs/command_reference/index.rst Command Reference に schedule_actual を追加
    docs/command_reference/schedule_actual/index.rst schedule_actual のコマンド一覧ページ追加
    docs/command_reference/schedule_actual/list_daily.rst list_daily のコマンドリファレンス追加
    docs/command_reference/schedule_actual/list_weekly.rst list_weekly のコマンドリファレンス追加
    AGENTS.md エージェント実行の前提/手順を追加
    .codex/config.toml Codex向けのsandbox/approval設定を追加
    .agents/skills/test-writing/SKILL.md テスト作成ガイドを追加
    .agents/skills/python-coding-style/SKILL.md Pythonコーディングスタイルを追加
    .agents/skills/document-style/SKILL.md ドキュメントスタイルを追加
    .agents/skills/annowork-cli-command-style/SKILL.md CLI規約(命名/ログ等)を追加

    Comment thread tests/schedule_actual/test_subcommand.py Outdated
    * `uv run pytest` を使う。

    ## テストコードの具体的なスタイル
    * テストファイルのディレクトリ構成やファイル名は、`annofabcli/`配下のプロダクションコードと対応させる。
    Copy link

    Copilot AI Apr 28, 2026

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    プロジェクトは annoworkcli なので、ここで例示しているパス annofabcli/ は誤記に見えます。テストディレクトリ構成の対応先を annoworkcli/ に修正してください。

    Suggested change
    * テストファイルのディレクトリ構成やファイル名は、`annofabcli/`配下のプロダクションコードと対応させる。
    * テストファイルのディレクトリ構成やファイル名は、`annoworkcli/`配下のプロダクションコードと対応させる。

    Copilot uses AI. Check for mistakes.
    * 何件目を処理しているかをログに出力する。
    * 100件や1000件など、適当な件数ごとに進捗をinfoレベルでログに出力する。
    * 全部の処理が完了した後に、成功件数、スキップ件数、失敗件数などのサマリをログにinfoレベルで出力する。
    * try-exceptでエラーをキャッチした場合は、`logger.warning(..., exc_info=True)`を使って、スタックとレースも出力する。
    Copy link

    Copilot AI Apr 28, 2026

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    誤記があります。「スタックとレース」→「スタックトレース」。

    Suggested change
    * try-exceptでエラーをキャッチした場合は、`logger.warning(..., exc_info=True)`を使って、スタックとレースも出力する
    * try-exceptでエラーをキャッチした場合は、`logger.warning(..., exc_info=True)`を使って、スタックトレースも出力する

    Copilot uses AI. Check for mistakes.
    @yuji38kwmt yuji38kwmt changed the title 202604 2 0101 schedule_actual コマンドの作成 Apr 28, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants