MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / totalCount

Method totalCount

github/PaginatedList.py:264–297  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

262
263 @property
264 def totalCount(self) -> int:
265 if self.__totalCount is None:
266 if self.is_rest:
267 params = self.__nextParams.copy()
268 # set per_page = 1 so the totalCount is just the number of pages
269 params.update({"per_page": 1})
270 headers, data = self.__requester.requestJsonAndCheck(
271 "GET", self.__firstUrl, parameters=params, headers=self.__headers # type: ignore
272 )
273 links = self.__parseLinkHeader(headers)
274 lastUrl = links.get("last")
275 if lastUrl:
276 self.__totalCount = int(parse_qs(lastUrl)["page"][0])
277 elif data and "total_count" in data:
278 self.__totalCount = data["total_count"]
279 elif data:
280 if isinstance(data, dict):
281 data = data[self.__list_item]
282 self.__totalCount = len(data)
283 else:
284 self.__totalCount = 0
285 else:
286 variables = self.__graphql_variables.copy()
287 if not self._reversed:
288 variables["first"] = 1
289 variables["after"] = None
290 else:
291 variables["last"] = 1
292 variables["before"] = None
293
294 _, data = self.__requester.graphql_query(self.__graphql_query, variables) # type: ignore
295 pagination = self._get_graphql_pagination(data["data"], self.__list_item) # type: ignore
296 self.__totalCount = pagination.get("totalCount")
297 return self.__totalCount # type: ignore
298
299 def _getLastPageUrl(self) -> str | None:
300 headers, data = self.__requester.requestJsonAndCheck(

Callers

nothing calls this directly

Calls 6

__parseLinkHeaderMethod · 0.95
requestJsonAndCheckMethod · 0.80
getMethod · 0.80
graphql_queryMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected