Skip to content

Commit

Permalink
Import fixes (#607)
Browse files Browse the repository at this point in the history
* Exclude placeholder devices from inactive node resurrection

* Fix: Spreadsheet LOS import has `SpreadsheetLinkStatus.` before the status notes

* Clean up node notes
  • Loading branch information
Andrew-Dickinson authored Oct 6, 2024
1 parent f4ceaf7 commit e23ec56
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/meshdb/utils/spreadsheet_import/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ def main():

logging.info(f"Doing one last scan pass to to check device / node activity consistency")
for node in models.Node.objects.filter(status=models.Node.NodeStatus.INACTIVE).prefetch_related("devices"):
if any(device.status == models.Device.DeviceStatus.ACTIVE for device in node.devices.all()):
logging.info(f"Found active devices on inactive node {node}, marking active")
if any(
device.status == models.Device.DeviceStatus.ACTIVE and "Placeholder Device" not in device.name
for device in node.devices.all()
):
logging.info(f"Found active non-placeholder devices on inactive node {node}, marking active")
node.status = models.Node.NodeStatus.ACTIVE
node.save()

Expand Down
2 changes: 1 addition & 1 deletion src/meshdb/utils/spreadsheet_import/parse_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def find_access_point_from_install_number(install_number: int) -> Optional[Acces
def create_spreadsheet_link_notes(spreadsheet_link: SpreadsheetLink):
notes = (
f"Imported from spreadsheet link row "
+ f"{spreadsheet_link.from_node_id}->{spreadsheet_link.to_node_id} ({spreadsheet_link.status})\n"
+ f"{spreadsheet_link.from_node_id}->{spreadsheet_link.to_node_id} ({spreadsheet_link.status.value})\n"
+ "\n".join(
s.strip()
for s in [spreadsheet_link.where_to_where, spreadsheet_link.notes, spreadsheet_link.comments]
Expand Down
13 changes: 4 additions & 9 deletions src/meshdb/utils/spreadsheet_import/parse_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def get_spreadsheet_node_notes(row: SpreadsheetRow) -> str:
if row.notes2:
notes = f"Spreadsheet Notes2 (#{row.id}):\n{row.notes}"

if notes:
notes += f"-------\n\n"

return notes


Expand Down Expand Up @@ -88,12 +85,10 @@ def get_or_create_node(
node.type = new_type

if row.notes or row.notes2:
node.notes += (
f"Spreadsheet Notes (#{row.id}):\n"
f"{row.notes if row.notes else None}\n\n"
f"Spreadsheet Notes2 (#{row.id}):\n"
f"{row.notes2 if row.notes2 else None}\n\n"
)
if row.notes:
node.notes += f"Spreadsheet Notes (#{row.id}):\n{row.notes}\n\n"
if row.notes2:
node.notes += f"Spreadsheet Notes2 (#{row.id}):\n{row.notes2}\n\n"

return node

Expand Down

0 comments on commit e23ec56

Please sign in to comment.