def get_pagination_from_cursor(cursor: Cursor, start: int, limit: int): total = cursor.count() results = cursor.skip(start).limit(limit) has_next = total > (start + limit) pagination = { "start": start, "limit": limit, "total": total, "hasNext": has_next, "results": list(results) } return pagination
def r_comments(self, rng): self.output.append("Comment Amount: %d" % Cursor.count( self.search('select_gtv', 'comment_date', datetime(rng[0], rng[1], 1), 0, 'comment_id')))
def r_articles(self, rng): self.output.append("Article Amount: %d" % Cursor.count( self.search('select_gtv', 'date', datetime(rng[0], rng[1], 1), 0, 'nr')))
def commentc(self): self.output.append("Comment Amount: %d" % Cursor.count(self.search('exists', 'comment_id')))
def articlec(self): self.output.append("Article Amount: %d" % Cursor.count(self.search('exists', 'nr')))
def miss_docs(self): self.output.append("Missing: %d" % Cursor.count(self.search('empty', 'cmt_count')))
def count_docs(self): """ Count the amount of populated docs. """ self.output.append("Populated: %d" % Cursor.count(self.search('filled', 'cmt_count')))