feat: add Fleet operations view
This commit is contained in:
1 parent
c6d01df31c
commit
786a1ab910
12 files changed
+1062
-148
No files matched your search
@@ -79,16 +79,37 @@ class InventoryService:
|
||||
|
||||
@classmethod
|
||||
def _summary_model(cls, row: dict) -> InventoryMinerSummary:
|
||||
active_repair = None
|
||||
if row.get("active_repair_id") is not None:
|
||||
active_repair = {
|
||||
"id": row["active_repair_id"],
|
||||
"status": row["active_repair_status"],
|
||||
"reason": row["active_repair_reason"],
|
||||
}
|
||||
return InventoryMinerSummary(
|
||||
id=row["id"],
|
||||
asset_id=row.get("asset_tag"),
|
||||
current_mac=row.get("current_mac"),
|
||||
current_ip=row.get("current_ip"),
|
||||
model=row.get("model"),
|
||||
miner_sn=row.get("miner_sn"),
|
||||
lifecycle_status=row["lifecycle_status"],
|
||||
runtime_status=row["status"],
|
||||
site_id=row.get("site_id"),
|
||||
site_name=row.get("site_name"),
|
||||
room_id=row.get("room_id"),
|
||||
room_name=row.get("room_name"),
|
||||
location_position_id=row.get("location_position_id"),
|
||||
rack_label=row.get("rack_label"),
|
||||
shelf_label=row.get("shelf_label"),
|
||||
position_label=row.get("position_label"),
|
||||
position_index=row.get("position_index"),
|
||||
observed_at=row.get("observed_at"),
|
||||
hashrate_ths=row.get("hashrate_ths"),
|
||||
power_w=row.get("power_w"),
|
||||
chip_temp_max_c=row.get("chip_temp_max_c"),
|
||||
hash_stable=row.get("hash_stable"),
|
||||
active_repair=active_repair,
|
||||
tags=[cls._tag_model(tag) for tag in row.get("tags") or []],
|
||||
created_at=row["created_at"],
|
||||
updated_at=row["updated_at"],
|
||||
@@ -101,7 +122,6 @@ class InventoryService:
|
||||
return InventoryMinerDetail(
|
||||
**summary.model_dump(),
|
||||
hostname=row.get("hostname"),
|
||||
miner_sn=row.get("miner_sn"),
|
||||
control_board_sn=row.get("control_board_sn"),
|
||||
psu_serial=row.get("power_sn"),
|
||||
firmware_version=row.get("firmware_version"),
|
||||
@@ -140,12 +160,18 @@ class InventoryService:
|
||||
def search_miners(
|
||||
self,
|
||||
filters: InventorySearchFilters,
|
||||
*,
|
||||
include_location_details: bool = False,
|
||||
) -> list[InventoryMinerSummary]:
|
||||
lifecycle_status = None
|
||||
if filters.lifecycle_status:
|
||||
lifecycle_status = self.validate_lifecycle_status(
|
||||
filters.lifecycle_status
|
||||
)
|
||||
if (filters.site_id or filters.room_id) and not include_location_details:
|
||||
raise InventoryValidationError(
|
||||
"Location filters require location viewing permission"
|
||||
)
|
||||
asset_id = None
|
||||
if filters.asset_id:
|
||||
asset_id = self.normalize_asset_id(filters.asset_id)
|
||||
@@ -158,12 +184,23 @@ class InventoryService:
|
||||
query=self._clean_optional_text(filters.query),
|
||||
asset_id=asset_id,
|
||||
lifecycle_status=lifecycle_status,
|
||||
model=self._clean_optional_text(filters.model),
|
||||
runtime_status=self._clean_optional_text(filters.runtime_status),
|
||||
repair=filters.repair,
|
||||
operational_state=filters.operational_state,
|
||||
problems=filters.problems,
|
||||
site_id=filters.site_id,
|
||||
room_id=filters.room_id,
|
||||
tag_names=tag_names,
|
||||
limit=filters.limit,
|
||||
offset=filters.offset,
|
||||
include_location_details=include_location_details,
|
||||
)
|
||||
]
|
||||
|
||||
def list_location_filter_options(self) -> dict[str, list[dict]]:
|
||||
return self.repository.list_location_filter_options()
|
||||
|
||||
def create_miner(
|
||||
self,
|
||||
request: InventoryCreateRequest,
|
||||
|
||||
Reference in new issue
Block a user