Get all data and display the page
16951
def page(self, course):
        
        data = list(self.database.user_tasks.aggregate(
            [
                {
                    "$match":
                        {
                            "courseid": course.get_id(),
                            "username": {"$in": self.user_manager.get_course_registered_users(course, False)}
                        }
                },
                {
                    "$group":
                        {
                            "_id": "$taskid",
                            "viewed": {"$sum": 1},
                            "attempted": {"$sum": {"$cond": [{"$ne": ["$tried", 0]}, 1, 0]}},
                            "attempts": {"$sum": "$tried"},
                            "succeeded": {"$sum": {"$cond": ["$succeeded", 1, 0]}}
                        }
                }
            ]))

        # Load tasks and verify exceptions
        files = self.task_factory.get_readable_tasks(course)
        output = {}
        errors = []
        for task in files:
            try:
                output[task] = course.get_task(task)
            except Exception as inst:
                errors.append({"taskid": task, "error": str(inst)})
        tasks = OrderedDict(sorted(list(output.items()), key=lambda t: (t[1].get_order(), t[1].get_id())))

        # Now load additional informations
        result = OrderedDict()
        for taskid in tasks:
            result[taskid] = {"name": tasks[taskid].get_name(self.user_manager.session_language()), "viewed": 0, "attempted": 0, "attempts": 0, "succeeded": 0,
                              "url": self.submission_url_generator(taskid)}
        for entry in data:
            if entry["_id"] in result:
                result[entry["_id"]]["viewed"] = entry["viewed"]
                result[entry["_id"]]["attempted"] = entry["attempted"]
                result[entry["_id"]]["attempts"] = entry["attempts"]
                result[entry["_id"]]["succeeded"] = entry["succeeded"]
        if "csv" in web.input():
            return make_csv(result)
        return self.template_helper.get_renderer().course_admin.task_list(course, result, errors)
778661
public function getData($page)
    {
        $this->loadData();
        $start = ($page - 1) * $this->pageSize;

        return array_slice($this->filteredData, $start, $this->pageSize);
    }
212448
def fetch_items(self):
        
        offset = self.per_page * (self.page - 1)
        items = self._query.limit(self.per_page).offset(offset).all()
        return items
718559
def get_all(self, qry, tpl):
        '''  '''
        self.cur.execute(qry, tpl)
        result = self.cur.fetchall()
        return result
1053623
def _fetch_all(cls, api_key, endpoint=None, offset=0, limit=25, **kwargs):
        
        output = []
        qp = kwargs.copy()
        limit = max(1, min(100, limit))
        maximum = kwargs.get('maximum')
        qp['limit'] = min(limit, maximum) if maximum is not None else limit
        qp['offset'] = offset
        more, total = None, None

        while True:
            entities, options = cls._fetch_page(
                api_key=api_key, endpoint=endpoint, **qp
            )
            output += entities
            more = options.get('more')
            limit = options.get('limit')
            offset = options.get('offset')
            total = options.get('total')

            if more is None:
                if total is None or offset is None:
                    break
                more = (limit + offset) < total

            if not more or (maximum is not None and len(output) >= maximum):
                break

            qp['limit'] = limit
            qp['offset'] = offset + limit

        return output
1021675
public function getData()
    {
        $limit = $this->getLimit();
        $this->setHeaders();
        $page  = $this->getPage();
        if ($page > 0) {
            $page-=1;
        }
        return $this->getDataSource()->limit($limit)->offset($limit * $page)->getAll();
    }
138531
def initialize_page_data(self):
        """"""
        if self.term.is_a_tty:
            self.display_initialize()
        self.character_generator = self.character_factory(self.screen.wide)
        page_data = list()
        while True:
            try:
                page_data.append(next(self.character_generator))
            except StopIteration:
                break
        if LIMIT_UCS == 0x10000:
            echo(self.term.center('press any key.').rstrip())
            flushout()
            self.term.inkey(timeout=None)
        return page_data
64750
def pages(self):
        
        url = self._build_url('pages', base_url=self._api)
        json = self._json(self._get(url), 200)
        return PagesInfo(json) if json else None
558598
public function allData()
    {
        call_user_func($this->callback, new ChartWidget($this->name, $this->label, $this->authSystem, $this->requiredPermissions, $this->chart));
    }
627522
def fetch(self, resource_data=None):
        """"""
        if not self._populated:
            params = {
                "Page"      : self.page,
                "PageSize"  : self.page_size,
            }

            params.update(self._filters)

            if not resource_data:
                self._resource_data = self._client._get(self._url + ".json", params)
            else:
                self._resource_data = resource_data

            self.total = self._resource_data["total"]
            self._page_start = self._resource_data["start"]
            self._page_end = self._resource_data["end"]

            self._populated = True
61179
def get_pages_for_display(self):
        """"""
        parent_page = self.parent_page_for_menu_items
        pages = self.get_base_page_queryset().filter(
            depth__gt=parent_page.depth,
            depth__lte=parent_page.depth + self.max_levels,
            path__startswith=parent_page.path,
        )
        # Return 'specific' page instances if required
        if(self.use_specific == constants.USE_SPECIFIC_ALWAYS):
            return pages.specific()
        return pages
589963
def _iterate_through_pages(get_function, resource, **kwargs):
        

        request_data = True
        data = []
        page = 1

        while request_data:
            temp_response = get_function(page=page, **kwargs)
            if temp_response[resource]['@total'] != '0':
                data.append(temp_response)

            page += 1
            if page > int(
                math.ceil(
                    float(temp_response[resource]['@total']) / float(temp_response[resource]['@per_page'])
                )
            ):
                request_data = False
        return data
132308
def display_page(self):
        

        self._display_page = max(0, min(self.page_count - 1, self._display_page))
        return self._display_page
918545
def _get(self, *args, **kwargs):
        """"""
        prev_data = kwargs.pop('prev_data', [])
        resp = self._request('get', *args, **kwargs)
        resp_content = resp._content
        if not resp_content:
            # No content so its obviously not paginated
            return resp

        # if resp._content is a bytes object, decode it so we can loads it as json
        if isinstance(resp_content, bytes):
            resp_content = resp_content.decode('utf-8')

        # Load the json so we can use the data as python objects
        content = json.loads(resp_content)
        if 'pagination' not in content:
            # Result is not paginated
            return resp

        page_info = content['pagination']
        if not page_info['next_uri']:
            # next_uri is None when the cursor has been iterated to the last element
            content['data'].extend(prev_data)
            # If resp._content was is a bytes object, only set it as a bytes object
            if isinstance(resp_content, bytes):
                resp._content = json.dumps(content).decode('utf-8')
            else:
                resp._content = json.dumps(content)
            return resp

        prev_data.extend(content['data'])
        next_page_id = page_info['next_uri'].split('=')[-1]
        kwargs.update({
            'prev_data': prev_data,
            'params': {'starting_after': next_page_id}
        })
        return self._get(*args, **kwargs)
641213
public function handle_get_data() {
        $url = new UrlHelper ();
        $pageNumber = $url->get('pageNumber', 1);
        $perPage = $url->get('perPage', 10);
        $filters = $url->get("filters_json", "[]");

        $params = array(
            'skip' => ($pageNumber - 1) * $perPage,
            'take' => $perPage,
            'filters_json' => $filters
        );
        return array(
            'type' => 'json',
            'data' => array (
                'rows' => $this->dataProvider->getData($params)
            )
        );
    }
648191
public function getData()
    {
        $defaultLimit = $this->container->getParameter('pedro_teixeira_grid.pagination.limit');

        $page       = $this->request->query->get('page', 1);
        $limit      = $this->request->query->get('limit', $defaultLimit);
        $sortIndex  = $this->request->query->get('sort');
        $sortOrder  = $this->request->query->get('sort_order');
        $filters    = $this->request->query->get('filters', array());

        $page = intval(abs($page));
        $page = ($page <= 0 ? 1 : $page);

        $limit = intval(abs($limit));
        $limit = ($limit <= 0 ? $defaultLimit : $limit);

        /** @todo Remove the unnecessary iterations */

        // Check and change cascade array in get
        foreach ($filters as $key => $filter) {
            if (strpos($filter['name'], '[]') !== false) {

                unset($filters[$key]);
                $name = str_replace('[]', '', $filter['name']);

                if (!isset($filters[$name])) {
                    $filters[$name] = array(
                        'name' => $name,
                        'value' => array($filter['value'])
                    );
                } else {
                    $filters[$name]['value'][] = $filter['value'];
                }
            }
        }

        foreach ($filters as $filter) {
            /** @var \PedroTeixeira\Bundle\GridBundle\Grid\Column $column */
            foreach ($this->columns as $column) {
                if ($filter['name'] == $column->getIndex() && $filter['value'] != '') {
                    $column->getFilter()->execute($this->getQueryBuilder(), $filter['value']);
                }
            }
        }

        if ($sortIndex) {
            $this->getQueryBuilder()->orderBy($sortIndex, $sortOrder);
        }

        // Don't process grid for export
        if (!$this->isExport()) {
            $totalCount = count(new Paginator($this->getQueryBuilder()->getQuery()));

            $totalPages = ceil($totalCount / $limit);
            $totalPages = ($totalPages <= 0 ? 1 : $totalPages);

            $page = ($page > $totalPages ? $totalPages : $page);

            $queryOffset = (($page * $limit) - $limit);

            $this->getQueryBuilder()
                ->setFirstResult($queryOffset)
                ->setMaxResults($limit);

            $response = array(
                'page'       => $page,
                'page_count' => $totalPages,
                'page_limit' => $limit,
                'row_count'  => $totalCount,
                'rows'       => array()
            );
        } else {
            $response = array(
                'rows'       => array()
            );
        }

        foreach ($this->getQueryBuilder()->getQuery()->getResult() as $key => $row) {

            $rowValue = array();

            /** @var Column $column */
            foreach ($this->columns as $column) {

                if ($column->getExportOnly() && !$this->isExport()) {
                    continue;
                }

                $rowColumn = ' ';

                // Array
                if (array_key_exists($column->getField(), $row)) {

                    $rowColumn = $row[$column->getField()];

                // Array scalar
                } elseif (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) {

                    $rowColumn = $row[0][$column->getField()];

                // Object
                } elseif (method_exists($row, 'get' . ucfirst($column->getField()))) {

                    $method = 'get' . ucfirst($column->getField());
                    $rowColumn = $row->$method();

                // Object scalar
                } elseif (array_key_exists(0, $row) && method_exists($row[0], 'get' . ucfirst($column->getField()))) {

                    $method = 'get' . ucfirst($column->getField());
                    $rowColumn = $row[0]->$method();

                // Array
                } elseif ($column->getTwig()) {

                    $rowColumn = $this->templating->render(
                        $column->getTwig(),
                        array(
                            'row' => $row
                        )
                    );
                }

                $rowValue[$column->getField()] = $column->getRender()
                    ->setValue($rowColumn)
                    ->setStringOnly($this->isExport())
                    ->render();
            }

            $response['rows'][$key] = $rowValue;
        }

        return $response;
    }
487785
def fetch_and_parse(url, bodyLines):
    """"""

    pageHtml = fetch_page(url)
    return parse(url, pageHtml, bodyLines)