def get_catalog(self, data): if data is None: raise TypeError fixed = data["fixed"] if fixed: # the client is asking a full collection (i.e. a collection that doesn't require server side pagination) # return the collection; but only if it doesn't exceeds a reasonable maximum all_data = self.get_all() all_data = ListUtils.optimize_list(all_data) if len(all_data) <= MAXIMUM_COLLECTION_LENGTH: return all_data # timestamp = data["timestamp"] # timestamp of the first time a page was required page_number = data["page"] page_size = data["size"] search = data["search"] if "search" in data else "" order_by = data["orderBy"] sort_order = data["sortOrder"] # get the collection collection, total_rows = self.get_catalog_page(page_number, page_size, search, order_by, sort_order) # optimize the collection collection = ListUtils.optimize_list(collection) result = { "subset": collection, "page": page_number, "total": total_rows } return result
def get_catalog(self, data): if data is None: raise TypeError fixed = data["fixed"] if fixed: # the client is asking a full collection (i.e. a collection that doesn't require server side pagination) # return the collection; but only if it doesn't exceeds a reasonable maximum all_data = self.get_all() all_data = ListUtils.optimize_list(all_data) if len(all_data) < MAXIMUM_COLLECTION_LENGTH: return all_data # timestamp = data["timestamp"] # timestamp of the first time a page was required page_number = data["page"] page_size = data["size"] search = data["search"] if "search" in data else "" order_by = data["orderBy"] sort_order = data["sortOrder"] # get the collection collection, total_rows = self.get_catalog_page(page_number, page_size, search, order_by, sort_order) # optimize the collection collection = ListUtils.optimize_list(collection) result = {"subset": collection, "page": page_number, "total": total_rows} return result
def get_catalog(self, data): if data is None: raise TypeError # timestamp = data["timestamp"] # timestamp of the first time a page was required page_number = data.get("page") page_size = data.get("size") search = data.get("search") sort_by = data.get("sortBy") # get the collection collection, total_rows = self.get_catalog_page(page_number, page_size, search, sort_by) # optimize the collection collection = ListUtils.optimize_list(collection) result = { "subset": collection, "page": page_number, "total": total_rows } return result