MCPcopy Create free account
hub / github.com/GerevAI/gerev / get_list

Method get_list

app/data_source/sources/bookstack/bookstack.py:60–77  ·  view source on GitHub ↗
(self, url: str, count: int = 500, sort: str = None, filters: Dict = None)

Source from the content-addressed store, hash-verified

58 return r
59
60 def get_list(self, url: str, count: int = 500, sort: str = None, filters: Dict = None):
61 # Add filter[...] to keys, avoiding the insertion of unwanted parameters
62 if filters is not None:
63 filters = {f"filter[{k}]": v for k, v in filters.items()}
64 else:
65 filters = {}
66
67 data = []
68 records = 0
69 total = 1 # Set 1 to enter the loop
70 while records < total:
71 r = self.get(url, params={"count": count, "offset": records, "sort": sort, **filters},
72 headers={"Content-Type": "application/json"})
73 json = r.json()
74 data += json.get("data")
75 records = len(data)
76 total = json.get("total")
77 return data
78
79 def get_all_books(self) -> List[Dict]:
80 return self.get_list("/api/books", sort="+updated_at")

Callers 2

get_all_booksMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected