Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import fixes #607

Merged
merged 4 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading