feat: add simulation settings and location board redesign
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@ from openpyxl import load_workbook
|
||||
from sqlalchemy import delete, select
|
||||
|
||||
from app.extensions import db
|
||||
from app.models import Asset, AssetLogEntry
|
||||
from app.models import Asset, AssetLogEntry, AssetStateNode
|
||||
|
||||
|
||||
EVENT_LINE_PATTERN = re.compile(r"^(\d{4}-\d{2}-\d{2})\s+(.+)$")
|
||||
@@ -99,6 +99,8 @@ def import_log_book_data(workbook_path: str | Path) -> LogBookImportSummary:
|
||||
except Exception:
|
||||
db.session.rollback()
|
||||
raise
|
||||
finally:
|
||||
workbook.close()
|
||||
|
||||
return summary
|
||||
|
||||
@@ -156,22 +158,39 @@ def _import_sheet(worksheet: object, sheet_name: str, asset_spec: dict[str, str]
|
||||
if log_name is None or start_at is None:
|
||||
continue
|
||||
|
||||
db.session.add(
|
||||
AssetLogEntry(
|
||||
asset_id=asset.id,
|
||||
entry_kind="state",
|
||||
entry = AssetLogEntry(
|
||||
asset_id=asset.id,
|
||||
entry_kind="state",
|
||||
title=log_name,
|
||||
mission_label=log_name,
|
||||
start_at=start_at,
|
||||
end_at=end_at,
|
||||
summary=mission_detail,
|
||||
note=sub_log,
|
||||
)
|
||||
entry.state_nodes.append(
|
||||
AssetStateNode(
|
||||
title=log_name,
|
||||
detail=mission_detail,
|
||||
at_time=start_at,
|
||||
target_location=inferred_location,
|
||||
state_label=log_name,
|
||||
mission_label=log_name,
|
||||
location=inferred_location,
|
||||
start_at=start_at,
|
||||
end_at=end_at,
|
||||
summary=mission_detail,
|
||||
note=sub_log,
|
||||
)
|
||||
)
|
||||
db.session.add(entry)
|
||||
summary.state_entries += 1
|
||||
|
||||
events = _parse_sub_log_events(
|
||||
asset.id,
|
||||
log_name,
|
||||
start_at,
|
||||
end_at,
|
||||
inferred_location,
|
||||
sub_log,
|
||||
)
|
||||
db.session.add_all(events)
|
||||
summary.event_entries += len(events)
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
@@ -260,19 +279,23 @@ def _parse_sub_log_events(
|
||||
continue
|
||||
|
||||
description = match.group(2).strip()
|
||||
events.append(
|
||||
AssetLogEntry(
|
||||
asset_id=asset_id,
|
||||
entry_kind="event",
|
||||
event = AssetLogEntry(
|
||||
asset_id=asset_id,
|
||||
entry_kind="event",
|
||||
title=description,
|
||||
mission_label=parent_title,
|
||||
start_at=event_at,
|
||||
end_at=None,
|
||||
summary=parent_title,
|
||||
note=line,
|
||||
)
|
||||
event.state_nodes.append(
|
||||
AssetStateNode(
|
||||
title=description,
|
||||
state_label=None,
|
||||
mission_label=parent_title,
|
||||
location=_infer_event_location(description, default_location),
|
||||
start_at=event_at,
|
||||
end_at=None,
|
||||
summary=parent_title,
|
||||
note=line,
|
||||
at_time=event_at,
|
||||
target_location=_infer_event_location(description, default_location),
|
||||
)
|
||||
)
|
||||
events.append(event)
|
||||
|
||||
return events
|
||||
return events
|
||||
|
||||
Reference in New Issue
Block a user