diff --git a/.github/workflows/yarn-scan-backend-go-pr.yml b/.github/workflows/yarn-scan-backend-go-pr.yml index bf2df01d2..9e63d1246 100644 --- a/.github/workflows/yarn-scan-backend-go-pr.yml +++ b/.github/workflows/yarn-scan-backend-go-pr.yml @@ -8,7 +8,7 @@ on: # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions pull_request: branches: - - main + - dev jobs: yarn-scan-backend-go-pr: diff --git a/.github/workflows/yarn-scan-backend-pr.yml b/.github/workflows/yarn-scan-backend-pr.yml index a86a6d372..4f8fa851e 100644 --- a/.github/workflows/yarn-scan-backend-pr.yml +++ b/.github/workflows/yarn-scan-backend-pr.yml @@ -8,7 +8,7 @@ on: # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions pull_request: branches: - - main + - dev jobs: yarn-scan-backend-pr: diff --git a/cla-backend-go/Makefile b/cla-backend-go/Makefile index 9584d3df1..6f64e78f8 100644 --- a/cla-backend-go/Makefile +++ b/cla-backend-go/Makefile @@ -69,7 +69,7 @@ setup-swagger: setup_dev: setup-dev setup-dev: - pushd /tmp && echo "==> Installing goimport..." && go install golang.org/x/tools/cmd/goimports@latest && echo "==> Installation coverage tools..." && go install golang.org/x/tools/cmd/cover@latest && popd + pushd /tmp && echo "==> Installing goimport..." && go install golang.org/x/tools/cmd/goimports@v0.24.0 && echo "==> Installation coverage tools..." && go install golang.org/x/tools/cmd/cover@latest && popd @echo "==> Installing linter..." @# Latest releases: https://github.com/golangci/golangci-lint/releases diff --git a/cla-backend/cla/models/dynamo_models.py b/cla-backend/cla/models/dynamo_models.py index ec92d62f5..2ceaed90f 100644 --- a/cla-backend/cla/models/dynamo_models.py +++ b/cla-backend/cla/models/dynamo_models.py @@ -500,6 +500,20 @@ class Meta: organization_name_lower = UnicodeAttribute(hash_key=True) +class OrganizationNameLowerSearchIndex(GlobalSecondaryIndex): + """ + This class represents a global secondary index for querying organizations by Organization Name. + """ + + class Meta: + """Meta class for external ID github org index.""" + + index_name = "organization-name-lower-search-index" + write_capacity_units = int(cla.conf["DYNAMO_WRITE_UNITS"]) + read_capacity_units = int(cla.conf["DYNAMO_READ_UNITS"]) + projection = AllProjection() + + organization_name_lower = UnicodeAttribute(hash_key=True) class GitlabExternalGroupIDIndex(GlobalSecondaryIndex): """ @@ -3817,7 +3831,8 @@ class Meta: project_sfid = UnicodeAttribute() organization_sfid_index = GitlabOrgSFIndex() project_sfid_organization_name_index = GitlabOrgProjectSfidOrganizationNameIndex() - organization_name_lowe_index = GitlabOrganizationNameLowerIndex() + organization_name_lower_index = GitlabOrganizationNameLowerIndex() + organization_name_lower_search_index = OrganizationNameLowerSearchIndex() organization_project_id = UnicodeAttribute(null=True) organization_company_id = UnicodeAttribute(null=True) auto_enabled = BooleanAttribute(null=True) @@ -3964,7 +3979,7 @@ def get_organization_by_installation_id(self, installation_id): return None def get_organization_by_lower_name(self, organization_name): - org_generator = self.model.scan(organization_name_lower__eq=organization_name.lower()) + org_generator = self.model.organization_name_lower_search_index.query(organization_name.lower()) for org_model in org_generator: org = GitHubOrg() org.model = org_model diff --git a/cla-backend/cla/tests/unit/test_gh_org_models.py b/cla-backend/cla/tests/unit/test_gh_org_models.py index f37dfeced..0828d0d7e 100644 --- a/cla-backend/cla/tests/unit/test_gh_org_models.py +++ b/cla-backend/cla/tests/unit/test_gh_org_models.py @@ -35,6 +35,6 @@ def test_set_organization_name(gh_instance): def test_get_org_by_name_lower(gh_instance): """ Test getting GitHub org with case insensitive search """ gh_org = cla.utils.get_github_organization_instance() - gh_org.model.scan = Mock(return_value=[gh_instance.model]) + gh_org.model.organization_name_lower_search_index.query = Mock(return_value=[gh_instance.model]) found_gh_org = gh_org.get_organization_by_lower_name(gh_instance.get_organization_name()) assert found_gh_org.get_organization_name_lower() == gh_instance.get_organization_name_lower()