def get_latest_items(query_base, sort_col: Column, limit: int):
    return query_base.order_by(Item.open_timestamp.desc()) \
        .limit(15) \
        .from_self() \
        .order_by(sort_col.asc(), Item.open_timestamp.desc()) \
        .limit(limit) \
        .all()
Example #2
0
 def _windowed_lru_digests(self, q: Query,
                           column: Column) -> Iterable[IndexEntry]:
     """ Generate a query for each window produced by _column_windows
     and yield the results one by one.
     """
     for whereclause in self._column_windows(q.session, column):
         window = q.filter(whereclause).order_by(column.asc())
         yield from window
Example #3
0
def create_query_table(table_name: base, current_page: int,
                       column_name_for_order: Column):
    """Get a limit count of author or genre or reader records from the DB."""
    offset = LIMIT * current_page
    result: table_name = session \
        .query(table_name) \
        .order_by(column_name_for_order.asc()) \
        .offset(offset) \
        .limit(LIMIT) \
        .all()
    return result
Example #4
0
def AdminGroup(models):

    id = Column(Integer, primary_key=True)
    title = Column(String(250), nullable=False, unique=True)
    order = Column(Integer, nullable=False, default=0)

    __mapper_args__ = {'order_by': order.asc()}

    @property
    def ru_title(self):
        from admin.streams.admins import ROLES
        return dict(ROLES).get(self.title)