Skip to content

Commit

Permalink
pagination added to get events
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastheman committed Oct 20, 2023
1 parent a8929b1 commit b99e593
Show file tree
Hide file tree
Showing 5 changed files with 588 additions and 396 deletions.
20 changes: 10 additions & 10 deletions fedn/fedn/network/api/interface.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import base64
import copy
import json

import os
import threading
from io import BytesIO

from bson import json_util
from flask import jsonify, send_from_directory
from werkzeug.utils import secure_filename

Expand Down Expand Up @@ -380,19 +379,20 @@ def get_events(self, **kwargs):
:return: The events as a json object.
:rtype: :py:class:`flask.Response`
"""
event_objects = self.statestore.get_events(**kwargs)
if event_objects is None:
response = self.statestore.get_events(**kwargs)

result = response["result"]
if result is None:
return (
jsonify({"success": False, "message": "No events found."}),
404,
)
json_docs = []
for doc in self.statestore.get_events(**kwargs):
json_doc = json.dumps(doc, default=json_util.default)
json_docs.append(json_doc)

json_docs.reverse()
return jsonify({"events": json_docs})
events = []
for evt in result:
events.append(evt)

return jsonify({"result": events, "count": response["count"]})

def get_all_validations(self, **kwargs):
"""Get all validations from the statestore.
Expand Down
2 changes: 0 additions & 2 deletions fedn/fedn/network/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ def get_events():
# TODO: except filter with request.get_json()
kwargs = request.args.to_dict()

print("get_events")
print(kwargs)
return api.get_events(**kwargs)


Expand Down
Loading

0 comments on commit b99e593

Please sign in to comment.