Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge staging to main: Heartbeat & locations sorting changes #420

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion rorapi/common/record_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def get_lang_code(lang_string):
def get_file_from_url(url):
rsp = requests.get(url)
rsp.raise_for_status()
print(rsp.json())
return rsp.json()

def validate_record(data, schema):
Expand Down
8 changes: 5 additions & 3 deletions rorapi/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rorapi.common.create_update import new_record_from_json, update_record_from_json
from rorapi.common.csv_bulk import process_csv
from rorapi.common.csv_utils import validate_csv
from rorapi.settings import REST_FRAMEWORK
from rorapi.settings import REST_FRAMEWORK, ES7, ES_VARS
from rorapi.common.matching import match_organizations
from rorapi.common.models import (
Errors
Expand Down Expand Up @@ -175,8 +175,10 @@ class HeartbeatView(View):
def get(self, request, version=REST_FRAMEWORK["DEFAULT_VERSION"]):
print(version)
try:
errors, organizations = search_organizations({}, version)
if errors is None:
index = ES_VARS['INDEX_V1']
if version == 'v2':
index = ES_VARS['INDEX_V2']
if ES7.indices.exists(index):
return HttpResponse("OK")
except:
pass
Expand Down
6 changes: 2 additions & 4 deletions rorapi/tests/tests_integration/tests_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,9 @@ def verify_filtering(self, query):
self.assertTrue(self.get_total(output) <= co_aggr['count'])
for i in output['items']:
self.assertTrue(t_aggr['title'] in i['types'])
self.assertEquals(c_aggr['id'].upper(),
i['locations'][0]['geonames_details']['country_code'])
self.assertTrue(c_aggr['id'].upper() in [l['geonames_details']['country_code'] for l in i['locations']])
self.assertTrue(s_aggr['title'] in i['status'])
self.assertEquals(co_aggr['id'].upper(),
i['locations'][0]['geonames_details']['continent_code'])
self.assertTrue(co_aggr['id'].upper() in [l['geonames_details']['continent_code'] for l in i['locations']])
self.assertTrue(
any([t_aggr['id'] == t['id']
for t in output['meta']['types']]))
Expand Down
3 changes: 1 addition & 2 deletions rorapi/v2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def __init__(self, data):
]
sorted_links = sorted(data.links, key=lambda x: x['type'])
self.links = [Entity(l, ["value", "type"]) for l in sorted_links]
sorted_locations = sorted(data.locations, key=lambda x: x['geonames_id'])
self.locations = [Location(l) for l in sorted_locations]
self.locations = [Location(l) for l in data.locations]
sorted_names = sorted(data.names, key=lambda x: x['value'])
self.names = [Entity(n, ["value", "lang", "types"]) for n in sorted_names]
sorted_rels = sorted(data.relationships, key=lambda x: x['type'])
Expand Down
1 change: 0 additions & 1 deletion rorapi/v2/record_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"domains": None,
"external_ids": "type",
"links": "type",
"locations": "geonames_id",
"names": "value",
"relationships": "type",
"types": None
Expand Down
Loading