Skip to content

Commit

Permalink
Merge pull request #752 from SmartThingsCommunity/bugfix/CHAD-10893-c…
Browse files Browse the repository at this point in the history
…heck-duplicate-profile-metadata

Check metadata when comparing profiles for duplicate detection
  • Loading branch information
ctowns authored Jun 6, 2023
2 parents 019c340 + 0cd953b commit 28c8c5b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/scripts/check_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def compare_preferences(prof1, prof2):
else:
return False

def compare_metadata(prof1, prof2):
if "metadata" in prof1 and "metadata" in prof2:
return prof1["metadata"] == prof2["metadata"]
elif "metadata" not in prof1 and "metadata" not in prof2:
return True
else:
return False

def compare_components(prof1, prof2):
if len(prof1["components"]) == len(prof2["components"]):
for y, new_component in enumerate(prof1["components"]):
Expand Down Expand Up @@ -119,6 +127,7 @@ def compare_components(prof1, prof2):
- preferences must be the same
'''
if(compare_preferences(new_profile_map, current_profile_map) == True and
compare_metadata(new_profile_map, current_profile_map) == True and
compare_components(new_profile_map, current_profile_map) == True):
print("%s and %s are duplicates!\n" % (new_profile, current_profile))
duplicate_pairs.append((new_profile, current_profile))
Expand Down

0 comments on commit 28c8c5b

Please sign in to comment.