Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
 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')))
Ejemplo n.º 3
0
 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')))
Ejemplo n.º 4
0
 def commentc(self):
     self.output.append("Comment Amount: %d" %
                        Cursor.count(self.search('exists', 'comment_id')))
Ejemplo n.º 5
0
 def articlec(self):
     self.output.append("Article Amount: %d" %
                        Cursor.count(self.search('exists', 'nr')))
Ejemplo n.º 6
0
 def miss_docs(self):
     self.output.append("Missing: %d" %
                        Cursor.count(self.search('empty', 'cmt_count')))
Ejemplo n.º 7
0
 def count_docs(self):
     """ Count the amount of populated docs. """
     self.output.append("Populated: %d" %
                        Cursor.count(self.search('filled', 'cmt_count')))