Include the schedule data date (last_recalc_date from XER) in the get_project_summary tool response. This shows when the schedule was last calculated in P6. Changes: - Add last_recalc_date column to projects table schema - Parse last_recalc_date in PROJECT table handler - Include last_recalc_date in db loader - Return data_date field in get_project_summary query - Update contract test to verify data_date presence
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""PROJECT table handler."""
|
|
|
|
from xer_mcp.parser.table_handlers.base import TableHandler
|
|
|
|
|
|
def convert_date(date_str: str | None) -> str | None:
|
|
"""Convert XER date format to ISO8601.
|
|
|
|
XER format: "YYYY-MM-DD HH:MM"
|
|
ISO8601 format: "YYYY-MM-DDTHH:MM:SS"
|
|
"""
|
|
if not date_str or date_str.strip() == "":
|
|
return None
|
|
# Replace space with T and add seconds
|
|
return date_str.replace(" ", "T") + ":00"
|
|
|
|
|
|
class ProjectHandler(TableHandler):
|
|
"""Handler for PROJECT table in XER files."""
|
|
|
|
@property
|
|
def table_name(self) -> str:
|
|
return "PROJECT"
|
|
|
|
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
|
|
"""Parse a PROJECT row."""
|
|
if len(values) < len(fields):
|
|
# Pad with empty strings if needed
|
|
values = values + [""] * (len(fields) - len(values))
|
|
|
|
data = dict(zip(fields, values, strict=False))
|
|
|
|
return {
|
|
"proj_id": data.get("proj_id", ""),
|
|
"proj_short_name": data.get("proj_short_name", ""),
|
|
"plan_start_date": convert_date(data.get("plan_start_date")),
|
|
"plan_end_date": convert_date(data.get("plan_end_date")),
|
|
"last_recalc_date": convert_date(data.get("last_recalc_date")),
|
|
}
|