Skip to content

Commit

Permalink
Merge pull request #311 from gsfk/fix-response-summary
Browse files Browse the repository at this point in the history
fix response summary
  • Loading branch information
costero-e authored Apr 11, 2024
2 parents d20884f + 8f9e53f commit bd2fb14
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions beacon/response/build_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,17 @@ def build_meta(qparams: RequestParams, entity_schema: Optional[DefaultSchemas],
}
return meta

def build_response_summary(exists, qparams, num_total_results):
limit = qparams.query.pagination.limit
include = qparams.query.include_resultset_responses
def build_response_summary(exists, num_total_results):
LOG.debug(num_total_results)
#if limit != 0 and limit < num_total_results:
if include == 'NONE':
if num_total_results is None:
return {
'exists': exists
}
else:
return {
'exists': exists,
'numTotalResults': num_total_results
}
elif limit and num_total_results and limit < num_total_results:
if num_total_results is None:
return {
'exists': exists
}
else:
return {
'exists': exists,
'numTotalResults': limit
}
if num_total_results is None:
return {
'exists': exists
}
else:
if num_total_results is None:
return {
'exists': exists
}
else:
return {
'exists': exists,
'numTotalResults': num_total_results
}
return {
'exists': exists,
'numTotalResults': num_total_results
}


def build_response_summary_by_dataset(exists, num_total_results, data):
Expand Down Expand Up @@ -152,7 +128,7 @@ def build_beacon_resultset_response(data,

beacon_response = {
'meta': build_meta(qparams, entity_schema, Granularity.RECORD),
'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results),
'responseSummary': build_response_summary(num_total_results > 0, num_total_results),
# TODO: 'extendedInfo': build_extended_info(),
'response': {
'resultSets': [build_response(data, num_total_results, qparams, func_response_type)]
Expand Down Expand Up @@ -198,7 +174,7 @@ def build_beacon_count_response(data,

beacon_response = {
'meta': build_meta(qparams, entity_schema, Granularity.COUNT),
'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results),
'responseSummary': build_response_summary(num_total_results > 0, num_total_results),
# TODO: 'extendedInfo': build_extended_info(),
'beaconHandovers': beacon_handovers(),
}
Expand All @@ -219,7 +195,7 @@ def build_beacon_boolean_response(data,

beacon_response = {
'meta': build_meta(qparams, entity_schema, Granularity.BOOLEAN),
'responseSummary': build_response_summary(num_total_results > 0, qparams, None),
'responseSummary': build_response_summary(num_total_results > 0, None),
# TODO: 'extendedInfo': build_extended_info(),
'beaconHandovers': beacon_handovers(),
}
Expand All @@ -232,7 +208,7 @@ def build_beacon_boolean_response(data,
def build_beacon_collection_response(data, num_total_results, qparams: RequestParams, func_response_type, entity_schema: DefaultSchemas):
beacon_response = {
'meta': build_meta(qparams, entity_schema, Granularity.RECORD),
'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results),
'responseSummary': build_response_summary(num_total_results > 0, num_total_results),
# TODO: 'info': build_extended_info(),
'beaconHandovers': beacon_handovers(),
'response': {
Expand Down Expand Up @@ -320,7 +296,7 @@ def build_filtering_terms_response(data,

beacon_response = {
'meta': build_meta(qparams, entity_schema, Granularity.RECORD),
'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results),
'responseSummary': build_response_summary(num_total_results > 0, num_total_results),
# TODO: 'extendedInfo': build_extended_info(),
'response': {
'filteringTerms': data,
Expand Down

0 comments on commit bd2fb14

Please sign in to comment.