This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import argparse | |
import logging | |
from datetime import datetime, timedelta | |
from typing import List, Optional | |
from collections import defaultdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Vykreslení přehledu produktů v e-shopu | |
* | |
* @var Filter $filter Filtr, který omezuje množinu produktů podle nastavení uživatele | |
* @var int|null $limit Počet produktů zobrazených na stránce | |
* @var VisualPaginatorHelper $visualPaginatorHelper Jednoduchý helper, který pomáhá inicialzovat Paginator (Nette) | |
* @var VisualPaginator $visualPaginator VisualPaginator (Nette) | |
* @var Template $template Šablona view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pagination as a function | |
static IQueryable<T> Paginate<T>(this IQueryable<T> query, int pageNumber, int pageSize) => | |
query.Skip(pageSize*pageNumber).Take(pageSize); | |
// Usage | |
var paginatedQuery = originalQuery.Paginate(pageNumber, pageSize); | |
// Composition (fluent with extension methods) | |
var paginatedFilteredQuery = originalQuery.Where(predicate).Paginate(pageNumber, pageSize); |