Skip to content

Commit

Permalink
Merge pull request #956 from NASA-IMPACT/955-add-lrm-qa-servers-to-th…
Browse files Browse the repository at this point in the history
…e-list-of-instances-from-which-urls-can-be-pulled-in

Add LRM QA server to the list of instances from which URLs can be pulled in
  • Loading branch information
bishwaspraveen authored Aug 19, 2024
2 parents d139bbf + b9f3cef commit f903a32
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,5 @@
XLI_PASSWORD = env("XLI_PASSWORD")
LRM_USER = env("LRM_USER")
LRM_PASSWORD = env("LRM_PASSWORD")
LRM_QA_USER = env("LRM_QA_USER")
LRM_QA_PASSWORD = env("LRM_QA_PASSWORD")
10 changes: 9 additions & 1 deletion sde_collections/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from django.contrib import admin, messages
from django.http import HttpResponse

from .models.collection import Collection, WorkflowHistory
from .models.candidate_url import CandidateURL, ResolvedTitle
from .models.collection import Collection, WorkflowHistory
from .models.pattern import IncludePattern, TitlePattern
from .tasks import import_candidate_urls_from_api

Expand Down Expand Up @@ -143,6 +143,11 @@ def import_candidate_urls_lrm_dev_server(modeladmin, request, queryset):
import_candidate_urls_from_api_caller(modeladmin, request, queryset, "lrm_dev_server")


@admin.action(description="Import candidate URLs from LRM QA Server")
def import_candidate_urls_lrm_qa_server(modeladmin, request, queryset):
import_candidate_urls_from_api_caller(modeladmin, request, queryset, "lrm_qa_server")


class ExportCsvMixin:
def export_as_csv(self, request, queryset):
meta = self.model._meta
Expand Down Expand Up @@ -231,6 +236,7 @@ class CollectionAdmin(admin.ModelAdmin, ExportCsvMixin, UpdateConfigMixin):
import_candidate_urls_secret_production,
import_candidate_urls_lis_server,
import_candidate_urls_lrm_dev_server,
import_candidate_urls_lrm_qa_server,
]
ordering = ("cleaning_order",)

Expand Down Expand Up @@ -275,6 +281,7 @@ class TitlePatternAdmin(admin.ModelAdmin):
"collection",
)


class WorkflowHistoryAdmin(admin.ModelAdmin):
list_display = ("collection", "old_status", "workflow_status", "created_at")
search_fields = ["collection__name"]
Expand All @@ -284,6 +291,7 @@ class WorkflowHistoryAdmin(admin.ModelAdmin):
class ResolvedTitleAdmin(admin.ModelAdmin):
list_display = ["title_pattern", "candidate_url", "resolved_title", "created_at"]


admin.site.register(WorkflowHistory, WorkflowHistoryAdmin)
admin.site.register(CandidateURL, CandidateURLAdmin)
admin.site.register(TitlePattern, TitlePatternAdmin)
Expand Down
9 changes: 9 additions & 0 deletions sde_collections/sinequa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"query_name": "query-smd-primary",
"base_url": "https://sde-lrm.nasa-impact.net",
},
"lrm_qa_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "https://sde-qa.nasa-impact.net",
},
}


Expand All @@ -55,6 +60,8 @@ def __init__(self, server_name: str) -> None:
self.xli_password = settings.XLI_PASSWORD
self.lrm_user = settings.LRM_USER
self.lrm_password = settings.LRM_PASSWORD
self.lrm_qa_user = settings.LRM_QA_USER
self.lrm_qa_password = settings.LRM_QA_PASSWORD

def process_response(self, url: str, payload: dict[str, Any]) -> Any:
response = requests.post(url, headers={}, json=payload, verify=False)
Expand All @@ -71,6 +78,8 @@ def query(self, page: int, collection_config_folder: str = "") -> Any:
url = f"{self.base_url}/api/v1/search.query?Password={self.xli_password}&User={self.xli_user}"
elif self.server_name == "lrm_dev_server":
url = f"{self.base_url}/api/v1/search.query?Password={self.lrm_password}&User={self.lrm_user}"
elif self.server_name == "lrm_qa_server":
url = f"{self.base_url}/api/v1/search.query?Password={self.lrm_qa_password}&User={self.lrm_qa_user}"
else:
url = f"{self.base_url}/api/v1/search.query"
payload = {
Expand Down

0 comments on commit f903a32

Please sign in to comment.