MCPcopy Create free account
hub / github.com/alephdata/aleph / jsonify_result

Method jsonify_result

aleph/views/serializers.py:88–111  ·  view source on GitHub ↗
(cls, result, extra=None, **kwargs)

Source from the content-addressed store, hash-verified

86
87 @classmethod
88 def jsonify_result(cls, result, extra=None, **kwargs):
89 data = result.to_dict(serializer=cls)
90 if extra is not None:
91 data.update(extra)
92 # Sometimes part of the result might be missing because of some
93 # inconsistency (eg: a failed re-indexing). We try to spot those
94 # inconsistencies.
95 total = data.get("total", 0)
96 limit = data.get("limit", 0)
97 offset = data.get("offset", 0)
98 if total > 0 and not data.get("results"):
99 if not (limit == 0 or offset >= total):
100 log.exception(f"Expected more results in the response: {data}")
101 data = {
102 "status": "error",
103 "message": gettext(
104 "We found %(total)d results, but could not load them due "
105 "to a technical problem. Please check back later and if "
106 "the problem persists contact an Aleph administrator",
107 total=total,
108 ),
109 }
110 return jsonify(data, status=500)
111 return jsonify(data, **kwargs)
112
113
114class RoleSerializer(Serializer):

Callers 15

indexFunction · 0.80
indexFunction · 0.80
indexFunction · 0.80
indexFunction · 0.80
entities_indexFunction · 0.80
item_indexFunction · 0.80
indexFunction · 0.80
suggestFunction · 0.80
indexFunction · 0.80
similarFunction · 0.80
indexFunction · 0.80
matchFunction · 0.80

Calls 4

jsonifyFunction · 0.90
to_dictMethod · 0.45
updateMethod · 0.45
getMethod · 0.45