busy_beaver/common/wrappers/github.py
async def _get_items_after_timestamp(self, client, url, *, timestamp) -> List[Dict]:
        """Keep fetching until we have captured the timestamp or are on the last page"""
        all_items = []
        page_num = 1

        while True:
            combined_params = self.params | {"page": page_num}
            resp = await client.get(url, params=combined_params)
            if resp.status_code != 200:
                raise UnexpectedStatusCode
            all_items.extend(resp.json())

            single_page_of_activity = "Link" not in resp.headers
            if single_page_of_activity:
                break

            nav = ApiNav.parse_github_links(resp.headers["Link"])
            last_page = page_from_url(nav.last_link)
            min_batch_timestamp = date_parse(resp.json()[-1]["created_at"])
            keep_fetching = timestamp <= min_batch_timestamp and page_num < last_page
            if not keep_fetching:
                break

            page_num = page_num + 1

        filtered_items = filter_items_before(timestamp=timestamp, items=all_items)
        return filtered_items
Keep fetching until we have captured the timestamp or are on the last page
Keep fetching until we have captured the timestamp or are on the last page
Keep fetching until we have captured the timestamp or are on the last page
async def _get_items_after_timestamp(self, client, url, *, timestamp) -> List[Dict]:
        all_items = []
        page_num = 1
        while True:
            combined_params = self.params | {"page": page_num}
            resp = await client.get(url, params=combined_params)
            if resp.status_code != 200:
                raise UnexpectedStatusCode
            all_items.extend(resp.json())
            single_page_of_activity = "Link" not in resp.headers
            if single_page_of_activity:
                break
            nav = ApiNav.parse_github_links(resp.headers["Link"])
            last_page = page_from_url(nav.last_link)
            min_batch_timestamp = date_parse(resp.json()[-1]["created_at"])
            keep_fetching = timestamp <= min_batch_timestamp and page_num < last_page
            if not keep_fetching:
                break
            page_num = page_num + 1
        filtered_items = filter_items_before(timestamp=timestamp, items=all_items)
        return filtered_items
async def _get_items_after_timestamp ( self , client , url , * , timestamp ) -> List [ Dict ] : all_items = [ ] page_num = 1 while True : combined_params = self . params | { "page" : page_num } resp = await client . get ( url , params = combined_params ) if resp . status_code != 200 : raise UnexpectedStatusCode all_items . extend ( resp . json ( ) ) single_page_of_activity = "Link" not in resp . headers if single_page_of_activity : break nav = ApiNav . parse_github_links ( resp . headers [ "Link" ] ) last_page = page_from_url ( nav . last_link ) min_batch_timestamp = date_parse ( resp . json ( ) [ - 1 ] [ "created_at" ] ) keep_fetching = timestamp <= min_batch_timestamp and page_num < last_page if not keep_fetching : break page_num = page_num + 1 filtered_items = filter_items_before ( timestamp = timestamp , items = all_items ) return filtered_items
Keep fetching until we have captured the timestamp or are on the last page
Keep fetching until we have captured the timestamp or are on the last page
"""Keep fetching until we have captured the timestamp or are on the last page"""
self
client
url
timestamp