Skip to content

Commit

Permalink
Feedback | fixing sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 11, 2024
1 parent 321fa17 commit e67a640
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
19 changes: 15 additions & 4 deletions core/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,17 @@ def get_sort_attributes(self):
current_result = None
if field in ['score', '_score', 'best_match', 'best match']:
current_result = {'_score': order_details}
if self.is_concept_document() and field == 'name':
if field == 'name':
current_result = {'_name': order_details}
if field == 'id' and self.is_source_child_document_model():
current_result = {'id_lowercase': order_details}
if field in ['id', 'mnemonic'] and (
self.is_org_document() or self.is_concept_container_document_model() or
self.is_repo_document_model()
):
current_result = {'_mnemonic': order_details}
if field in ['username', 'id'] and self.is_user_document():
current_result = {'_username': order_details}
if self.is_valid_sort(field):
current_result = {field: order_details}
if current_result is not None:
Expand Down Expand Up @@ -466,6 +475,10 @@ def is_user_document(self):
from core.users.documents import UserProfileDocument
return self.document_model == UserProfileDocument

def is_org_document(self):
from core.orgs.documents import OrganizationDocument
return self.document_model == OrganizationDocument

def is_url_registry_document(self):
from core.url_registry.documents import URLRegistryDocument
return self.document_model == URLRegistryDocument
Expand All @@ -475,9 +488,7 @@ def is_concept_document(self):
return self.document_model == ConceptDocument

def is_owner_document_model(self):
from core.orgs.documents import OrganizationDocument
from core.users.documents import UserProfileDocument
return self.document_model in [UserProfileDocument, OrganizationDocument]
return self.is_org_document() or self.is_user_document()

def is_source_child_document_model(self):
from core.concepts.documents import ConceptDocument
Expand Down
4 changes: 2 additions & 2 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@
DEFAULT_LOCALES_REPO_URI = os.environ.get('DEFAULT_LOCALES_REPO_URI', '/orgs/ISO/sources/iso639-1/')

# keyCloak/OIDC Provider settings
OIDC_SERVER_URL = os.environ.get('OIDC_SERVER_URL', '')
OIDC_SERVER_URL = os.environ.get('OIDC_SERVER_URL', 'http://localhost:8080')
OIDC_RP_CLIENT_ID = '' # only needed a defined var in mozilla_django_oidc
OIDC_RP_CLIENT_SECRET = '' # only needed a defined var in mozilla_django_oidc
OIDC_SERVER_INTERNAL_URL = os.environ.get('OIDC_SERVER_INTERNAL_URL', '') or OIDC_SERVER_URL
OIDC_SERVER_INTERNAL_URL = os.environ.get('OIDC_SERVER_INTERNAL_URL', 'http://host.docker.internal:8080') or OIDC_SERVER_URL
OIDC_REALM = os.environ.get('OIDC_REALM', 'ocl')
OIDC_OP_AUTHORIZATION_ENDPOINT = f'{OIDC_SERVER_URL}/realms/{OIDC_REALM}/protocol/openid-connect/auth'
OIDC_OP_REGISTRATION_ENDPOINT = f'{OIDC_SERVER_URL}/realms/{OIDC_REALM}/protocol/openid-connect/registrations'
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
volumes:
- redis-data:/bitnami/redis/data
api:
image: openconceptlab/oclapi2:${ENVIRONMENT-production}
build: .
restart: "always"
ports:
- 8000:8000
Expand Down Expand Up @@ -68,7 +68,7 @@ services:
healthcheck:
test: "curl --silent --fail http://localhost:3500/ || exit 1"
celery:
image: openconceptlab/oclapi2:${ENVIRONMENT-production}
build: .
command: ["bash", "-c", "CELERY_WORKER_NAME=default ./start_celery_worker.sh -P prefork -Q default -c 2"]
restart: "always"
healthcheck:
Expand Down Expand Up @@ -100,7 +100,7 @@ services:
- ERRBIT_URL
- ERRBIT_KEY
celery_indexing:
image: openconceptlab/oclapi2:${ENVIRONMENT-production}
build: .
command: ["bash", "-c", "CELERY_WORKER_NAME=indexing ./start_celery_worker.sh -P prefork -Q indexing -c 2"]
restart: "always"
healthcheck:
Expand All @@ -112,8 +112,8 @@ services:
- ERRBIT_URL
- ERRBIT_KEY
celery_concurrent:
image: openconceptlab/oclapi2:${ENVIRONMENT-production}
command: ["bash", "-c", "CELERY_WORKER_NAME=concurrent ./start_celery_worker.sh -P prefork -Q concurrent -c 2"]
build: .
command: ["bash", "-c", "CELERY_WORKER_NAME=concurrent ./start_celery_worker.sh -P prefork -Q concurrent -c 4"]
restart: "always"
healthcheck:
test: ["CMD-SHELL", "-c", "CELERY_WORKER_NAME=concurrent ./ping_celery_worker.sh"]
Expand Down Expand Up @@ -154,7 +154,7 @@ services:
volumes:
- upload-data:/code/uploads
celery_bulk_import_root:
image: openconceptlab/oclapi2:${ENVIRONMENT-production}
build: .
command: ["bash", "-c", "CELERY_WORKER_NAME=bulk_import_root ./start_celery_worker.sh -Q bulk_import_root -c 1"]
restart: "always"
healthcheck:
Expand Down

0 comments on commit e67a640

Please sign in to comment.