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

Update comparison API #344

Merged
merged 1 commit into from
Aug 16, 2024
Merged
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
53 changes: 22 additions & 31 deletions biocompute/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,36 +909,27 @@ def post(self, request):
rejected_requests = False
accepted_requests = True
data = request.data
try:

for index, comparison in enumerate(data):
new_bco, old_bco = comparison
identifier = new_bco["object_id"]+ " vs " + old_bco["object_id"]

result = DeepDiff(new_bco, old_bco)
parsed_results = {
'dictionary_item_removed': list(result['dictionary_item_removed']),
'values_changed': list(result['values_changed']),
'iterable_item_removed': list(result['iterable_item_removed'])
}

for index, comparison in enumerate(data):
new_bco, old_bco = comparison
identifier = new_bco["object_id"]+ " vs " + old_bco["object_id"]

# new_results = validator.parse_and_validate(bco=new_bco)
# old_results = validator.parse_and_validate(bco=old_bco)
# import pdb; pdb.set_trace()
# new_identifier, new_results = new_results.popitem()
# old_identifier, old_results = bco_results.popitem()

# if results["number_of_errors"] > 0:
# rejected_requests = True
# bco_status = "FAILED"
# status_code = 400
# message = "BCO not valid"

# else:
# accepted_requests = True
# bco_status = "SUCCESS"
# status_code = 200
# message = "BCO valid"

response_data.append(bulk_response_constructor(
identifier = identifier,
status="SUCCESS",
code=200,
# message=message,
data=DeepDiff(new_bco, old_bco).to_json()
))
response_data.append(bulk_response_constructor(
identifier = identifier,
status="SUCCESS",
code=200,
data=parsed_results
))

status_code = response_status(accepted_requests, rejected_requests)
return Response(status=status_code, data=response_data)
status_code = response_status(accepted_requests, rejected_requests)
return Response(status=status_code, data=response_data)
except Exception:
return Response(status=status.HTTP_400_BAD_REQUEST, data={})
Loading