Skip to content

fix: get_subsidy_overview の accepting カウントが常に 0 になるバグを修正 / Fix accepting count always being 0 in get_subsidy_overview#2

Open
sugukurukabe wants to merge 1 commit intodigital-go-jp:mainfrom
sugukurukabe:fix/get-subsidy-overview-accepting-count
Open

fix: get_subsidy_overview の accepting カウントが常に 0 になるバグを修正 / Fix accepting count always being 0 in get_subsidy_overview#2
sugukurukabe wants to merge 1 commit intodigital-go-jp:mainfrom
sugukurukabe:fix/get-subsidy-overview-accepting-count

Conversation

@sugukurukabe
Copy link
Copy Markdown

問題 / Problem

get_subsidy_overview の戻り値の by_deadline_period.accepting が常に 0 になります。

The by_deadline_period.accepting field in get_subsidy_overview always returns 0.

再現手順 / Steps to reproduce

result = await get_subsidy_overview()
print(result["by_deadline_period"]["accepting"])
# => 常に 0 / Always 0

原因 / Root cause

core.py の集計ループ(L287–L313)では acceptance_end_datetime のみを確認し、this_month / next_month / after_next_month に分類しています。しかし accepting(現在受付中)を加算するロジックが存在しません。

The aggregation loop checks only acceptance_end_datetime to classify subsidies into this_month / next_month / after_next_month, but there is no logic to increment accepting (currently open for applications).

受付中の判定には両端チェックが必要です。
Determining "currently accepting" requires checking both start and end:

acceptance_start_datetime <= now <= acceptance_end_datetime

修正 / Fix

acceptance_end_datetime が未来であることを確認した後、acceptance_start_datetime <= now を追加でチェックし、accepting をインクリメントします。

After confirming acceptance_end_datetime is in the future, also check acceptance_start_datetime <= now and increment accepting.

# 現在受付中の判定: 開始日時が過去かつ終了日時が未来であること
# Check if currently accepting: start_datetime has passed and end_datetime is in the future
if subsidy.get("acceptance_start_datetime"):
    start_date = datetime.fromisoformat(
        subsidy["acceptance_start_datetime"].replace("Z", "+00:00")
    )
    if start_date <= now:
        stats["by_deadline_period"]["accepting"] += 1

変更内容 / Changes

  • jgrants_mcp_server/core.py: get_subsidy_overview の集計ループに accepting カウントのロジックを追加(9行追加)

テスト / Testing

この修正は acceptance_start_datetime が現在以前かつ acceptance_end_datetime が現在以後の補助金データが存在するときに accepting > 0 を返すようになります。

With this fix, accepting > 0 will be returned when subsidies have acceptance_start_datetime in the past and acceptance_end_datetime in the future.


JP Bids MCP(sugukurukabe/koko-call-mcp)との連携ガイドを整備する中で発見しました。
Found while writing an integration guide between JP Bids MCP and J-Grants MCP.

Made with Cursor

The 'accepting' bucket in by_deadline_period was always 0 because the
loop only checked acceptance_end_datetime to classify subsidies into
this_month / next_month / after_next_month, but never evaluated whether
acceptance_start_datetime had already passed.

Fix: after confirming end_date is in the future, also check that
acceptance_start_datetime <= now before incrementing 'accepting'.

Fixes the bug where get_subsidy_overview always returned:
  "by_deadline_period": { "accepting": 0, ... }

Co-authored-by: Cursor <[email protected]>
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.

1 participant