perceval/backends/core/gerrit.py
def _fetch_gerrit28(self, from_date=DEFAULT_DATETIME):
        """ Specific fetch for gerrit 2.8 version.

        Get open and closed reviews in different queries.
        Take the newer review from both lists and iterate.
        """

        # Convert date to Unix time
        from_ut = datetime_to_utc(from_date)
        from_ut = from_ut.timestamp()

        filter_open = "status:open"
        filter_closed = "status:closed"

        last_item_open = self.client.next_retrieve_group_item()
        last_item_closed = self.client.next_retrieve_group_item()
        reviews_open = self._get_reviews(last_item_open, filter_open)
        reviews_closed = self._get_reviews(last_item_closed, filter_closed)
        last_nreviews_open = len(reviews_open)
        last_nreviews_closed = len(reviews_closed)

        while reviews_open or reviews_closed:
            if reviews_open and reviews_closed:
                if reviews_open[0]['lastUpdated'] >= reviews_closed[0]['lastUpdated']:
                    review_open = reviews_open.pop(0)
                    review = review_open
                else:
                    review_closed = reviews_closed.pop(0)
                    review = review_closed
            elif reviews_closed:
                review_closed = reviews_closed.pop(0)
                review = review_closed
            else:
                review_open = reviews_open.pop(0)
                review = review_open

            updated = review['lastUpdated']
            if updated <= from_ut:
                logger.debug("No more updates for %s" % (self.hostname))
                break
            else:
                yield review

            if not reviews_open and last_nreviews_open >= self.max_reviews:
                last_item_open = self.client.next_retrieve_group_item(last_item_open, review_open)
                reviews_open = self._get_reviews(last_item_open, filter_open)
                last_nreviews_open = len(reviews_open)
            if not reviews_closed and last_nreviews_closed >= self.max_reviews:
                last_item_closed = self.client.next_retrieve_group_item(last_item_closed, review_closed)
                reviews_closed = self._get_reviews(last_item_closed, filter_closed)
                last_nreviews_closed = len(reviews_closed)
def _fetch_gerrit28(self, from_date=DEFAULT_DATETIME):
        # Convert date to Unix time
        from_ut = datetime_to_utc(from_date)
        from_ut = from_ut.timestamp()

        filter_open = "status:open"
        filter_closed = "status:closed"

        last_item_open = self.client.next_retrieve_group_item()
        last_item_closed = self.client.next_retrieve_group_item()
        reviews_open = self._get_reviews(last_item_open, filter_open)
        reviews_closed = self._get_reviews(last_item_closed, filter_closed)
        last_nreviews_open = len(reviews_open)
        last_nreviews_closed = len(reviews_closed)

        while reviews_open or reviews_closed:
            if reviews_open and reviews_closed:
                if reviews_open[0]['lastUpdated'] >= reviews_closed[0]['lastUpdated']:
                    review_open = reviews_open.pop(0)
                    review = review_open
                else:
                    review_closed = reviews_closed.pop(0)
                    review = review_closed
            elif reviews_closed:
                review_closed = reviews_closed.pop(0)
                review = review_closed
            else:
                review_open = reviews_open.pop(0)
                review = review_open

            updated = review['lastUpdated']
            if updated <= from_ut:
                logger.debug("No more updates for %s" % (self.hostname))
                break
            else:
                yield review

            if not reviews_open and last_nreviews_open >= self.max_reviews:
                last_item_open = self.client.next_retrieve_group_item(last_item_open, review_open)
                reviews_open = self._get_reviews(last_item_open, filter_open)
                last_nreviews_open = len(reviews_open)
            if not reviews_closed and last_nreviews_closed >= self.max_reviews:
                last_item_closed = self.client.next_retrieve_group_item(last_item_closed, review_closed)
                reviews_closed = self._get_reviews(last_item_closed, filter_closed)
                last_nreviews_closed = len(reviews_closed)
def _fetch_gerrit28 ( self , from_date = DEFAULT_DATETIME ) : # Convert date to Unix time from_ut = datetime_to_utc ( from_date ) from_ut = from_ut . timestamp ( ) filter_open = "status:open" filter_closed = "status:closed" last_item_open = self . client . next_retrieve_group_item ( ) last_item_closed = self . client . next_retrieve_group_item ( ) reviews_open = self . _get_reviews ( last_item_open , filter_open ) reviews_closed = self . _get_reviews ( last_item_closed , filter_closed ) last_nreviews_open = len ( reviews_open ) last_nreviews_closed = len ( reviews_closed ) while reviews_open or reviews_closed : if reviews_open and reviews_closed : if reviews_open [ 0 ] [ 'lastUpdated' ] >= reviews_closed [ 0 ] [ 'lastUpdated' ] : review_open = reviews_open . pop ( 0 ) review = review_open else : review_closed = reviews_closed . pop ( 0 ) review = review_closed elif reviews_closed : review_closed = reviews_closed . pop ( 0 ) review = review_closed else : review_open = reviews_open . pop ( 0 ) review = review_open updated = review [ 'lastUpdated' ] if updated <= from_ut : logger . debug ( "No more updates for %s" % ( self . hostname ) ) break else : yield review if not reviews_open and last_nreviews_open >= self . max_reviews : last_item_open = self . client . next_retrieve_group_item ( last_item_open , review_open ) reviews_open = self . _get_reviews ( last_item_open , filter_open ) last_nreviews_open = len ( reviews_open ) if not reviews_closed and last_nreviews_closed >= self . max_reviews : last_item_closed = self . client . next_retrieve_group_item ( last_item_closed , review_closed ) reviews_closed = self . _get_reviews ( last_item_closed , filter_closed ) last_nreviews_closed = len ( reviews_closed )
Specific fetch for gerrit 2.8 version.

        Get open and closed reviews in different queries.
        Take the newer review from both lists and iterate.
Specific fetch for gerrit 2 . 8 version .