From 600233d57fc06bf841da70e891be9945519c79c0 Mon Sep 17 00:00:00 2001 From: alexobaseki Date: Fri, 27 Sep 2024 14:14:43 -0400 Subject: [PATCH 1/4] Make match case insensitive --- openstates/importers/organizations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstates/importers/organizations.py b/openstates/importers/organizations.py index c24e6c7d..ffa422d7 100644 --- a/openstates/importers/organizations.py +++ b/openstates/importers/organizations.py @@ -15,6 +15,6 @@ def limit_spec(self, spec: _JsonDict) -> _JsonDict: name = spec.pop("name", None) if name: return Q(**spec) & ( - Q(name=name) | Q(other_names__contains=[{"name": name}]) + Q(name_iexact=name) | Q(other_names__icontains=[{"name": name}]) ) return spec From 560b27b49f4f3fd69f1d7cba8e5686c2a3b149d6 Mon Sep 17 00:00:00 2001 From: alexobaseki Date: Fri, 27 Sep 2024 17:04:43 -0400 Subject: [PATCH 2/4] Update limit_spec to be case insensitive --- openstates/importers/organizations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openstates/importers/organizations.py b/openstates/importers/organizations.py index ffa422d7..4b0db0b7 100644 --- a/openstates/importers/organizations.py +++ b/openstates/importers/organizations.py @@ -14,7 +14,10 @@ def limit_spec(self, spec: _JsonDict) -> _JsonDict: name = spec.pop("name", None) if name: + # __icontains doesn't work for JSONField ArrayField + # so other_names follows "title" naming pattern + other_names = name.title().replace(" On ", " on ") return Q(**spec) & ( - Q(name_iexact=name) | Q(other_names__icontains=[{"name": name}]) + Q(name__iexact=name) | Q(other_names__contains=[{"name": other_names}]) ) return spec From e004d87cb271ed7b207d343d575e03cfd8fa5971 Mon Sep 17 00:00:00 2001 From: alexobaseki Date: Fri, 27 Sep 2024 18:48:26 -0400 Subject: [PATCH 3/4] Update variable name --- openstates/importers/organizations.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openstates/importers/organizations.py b/openstates/importers/organizations.py index 4b0db0b7..9394c1ff 100644 --- a/openstates/importers/organizations.py +++ b/openstates/importers/organizations.py @@ -16,8 +16,9 @@ def limit_spec(self, spec: _JsonDict) -> _JsonDict: if name: # __icontains doesn't work for JSONField ArrayField # so other_names follows "title" naming pattern - other_names = name.title().replace(" On ", " on ") + other_name_lowercase_on = name.title().replace(" On ", " on ") return Q(**spec) & ( - Q(name__iexact=name) | Q(other_names__contains=[{"name": other_names}]) + Q(name__iexact=name) + | Q(other_names__contains=[{"name": other_name_lowercase_on}]) ) return spec From c1aad82bea02b355298fe356543eccd850c31637 Mon Sep 17 00:00:00 2001 From: alexobaseki Date: Mon, 30 Sep 2024 12:29:27 -0400 Subject: [PATCH 4/4] Update comment --- openstates/importers/organizations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstates/importers/organizations.py b/openstates/importers/organizations.py index 9394c1ff..5cc39ae5 100644 --- a/openstates/importers/organizations.py +++ b/openstates/importers/organizations.py @@ -15,7 +15,7 @@ def limit_spec(self, spec: _JsonDict) -> _JsonDict: name = spec.pop("name", None) if name: # __icontains doesn't work for JSONField ArrayField - # so other_names follows "title" naming pattern + # so other_name_lowercase_on follows "title" naming pattern other_name_lowercase_on = name.title().replace(" On ", " on ") return Q(**spec) & ( Q(name__iexact=name)