Skip to content

Commit

Permalink
Update scanner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Nov 14, 2024
1 parent ae2d077 commit f49851f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions stats-backend/api2/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ def update_providers_info(node_props):
new_provider_ids = set(provider_ids) - existing_provider_ids

# Create new Node instances if any
new_nodes = [Node(node_id=provider_id, type="provider") for provider_id in new_provider_ids]
if new_nodes:
Node.objects.bulk_create(new_nodes)
new_nodes = []
for provider_id in new_provider_ids:
node, created = Node.objects.get_or_create(
node_id=provider_id,
defaults={'type': 'provider'}
)
if created:
new_nodes.append(node)
existing_nodes_dict[node.node_id] = node


# Update existing_nodes_dict with newly created nodes
updated_nodes = Node.objects.filter(node_id__in=new_provider_ids)
Expand Down

0 comments on commit f49851f

Please sign in to comment.