From 71d28dbf1a845901856f5870d9d5982ce60d8a91 Mon Sep 17 00:00:00 2001
From: Anders Harrisson <anders.harrisson@ess.eu>
Date: Fri, 25 Oct 2024 10:40:16 +0200
Subject: [PATCH] Reverse the conditional for group associations

---
 netbox_awx_plugin/synchronization.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/netbox_awx_plugin/synchronization.py b/netbox_awx_plugin/synchronization.py
index 16ab564..2e727b1 100644
--- a/netbox_awx_plugin/synchronization.py
+++ b/netbox_awx_plugin/synchronization.py
@@ -96,7 +96,7 @@ def sync_host(inventory, sender, instance):
         else:
             logger.error(f"Invalid data for host_serializer: {host_serializer.errors}")
 
-    if len(host["summary_fields"]["groups"]["results"]) > host["summary_fields"]["groups"]["count"]:
+    if host["summary_fields"]["groups"]["count"] > len(host["summary_fields"]["groups"]["results"]):
         current_groups = inventory.get_host_groups(host['id'])
     else:
         current_groups = host["summary_fields"]["groups"]["results"]
-- 
GitLab