Retrieve a flat list of posts, regardless of specific hierarchy
971244
public function flatlist() {
		$replies = (bool) $this->owner->getRequest()->getVar('replies');
		
		$since = $this->owner->getRequest()->getVar('since');
		$before = (int) $this->owner->getRequest()->getVar('before');
		
		if (!$before) {
			$before = false;
		}
		
		$filter = array();
		
		$tags = $this->getFilterTags();
		
		$target = $this->getTargetFilter();
		if ($target) {
			$filter['Target'] = $target;
		}
		
		$sort = $this->request->getVar('sort');
		if (!$sort) {
			$sort = 'ID';
		}

        $mentions = (int) $this->getRequest()->getVar('mentions');
        if ($mentions) {
            $filter['Mentions.ID'] = Member::currentUserID();
        }

		$offset = $this->request->getVar('offset');
		
		$noReplies = $this->getOptions()->Replies;
		if (!$noReplies) {
			$replies = false;
		}
		
		if ($this->request->param('ID')) {
			$filter['ThreadID'] = (int) $this->request->param('ID');
		}

		$timeline = $this->owner->microBlogService->getStatusUpdates($filter, $sort, $since, $before, !$replies, $tags, $offset);

		$props = array(
			'Posts' => $timeline, 
			'Options' => $this->getOptions(),
			'QueryOffset'	=> $timeline->QueryOffset,
			'SortBy'		=> $sort,
			'Target'		=> $target,
			'ForceContent'		=> true
		);
		return trim($this->owner->customise($props)->renderWith('Timeline'));
	}
239145
def flat(self):
    """"""
    flat = []
    for kind, id in self.__pairs:
      flat.append(kind)
      flat.append(id)
    return tuple(flat)
581716
def visible_ancestors
      return [] unless parent
      if new_record?
        parent.visible_ancestors.tap do |base|
          base.push(parent) if parent.visible?
        end
      else
        ancestors.visible.contentpages.where(language_root: nil).to_a
      end
    end
30493
def get_allposts(self):
		''' 
		'''
		result = self.client.posts(self.blog, offset = 0, limit = 1)
		try: 
			total_posts = result['total_posts']
		except:
			raise phasetumblr_errors.TumblrBlogException(result['meta']['msg'])

		delta = (total_posts / 10) + 1

		all_posts = []
		posts_ids = []
		for j in range(delta):
			start = j * 10
			end = (j + 1) * 10
			posts = self.client.posts(self.blog, offset = start, limit = end)['posts']
			if not len(posts):
				break
			for i in posts:
				if i['id'] in posts_ids:
					continue
				description = split_body(i['body'])
				body = split_body(i['body'], 1)
				post = {}
				post['title'] = i['title']
				post['link'] = i['post_url']
				post['date'] = datetime.strptime(i['date'], '%Y-%m-%d %H:%M:%S %Z')
				post['tags'] = i['tags']
				post['id'] = i['id']
				post['body'] = body
				post['description'] = description
				all_posts.append(post)
				posts_ids.append(i['id'])

		newlist = sorted(all_posts, key=lambda k: k['date']) 
		return newlist
1097228
function listWithPublishedVersions(req, res) {
  const publishedString = '@published',
    options = {
      transforms() {
        return [filter({ wantStrings: true }, function (str) {
          return str.indexOf(publishedString) !== -1;
        })];
      }
    };

  // Trim the URI to `../pages` for the query to work
  req.uri = req.uri.replace(`/${publishedString}`, '');
  return list(options)(req, res);
}
839866
def list(self, wg_uuid, parent=None, flat=False, node_types=None):
        
        url = "%(base)s/%(wg_uuid)s/nodes" % {
            'base': self.local_base_url,
            'wg_uuid': wg_uuid
        }
        param = []
        if parent:
            # I use only the last folder uuid, the first ones are not really useful
            if isinstance(parent, (list,)):
                if len(parent) >= 1:
                    parent = parent[-1]
            param.append(("parent", parent))
        if flat:
            param.append(("flat", True))
        if node_types:
            for node_type in node_types:
                param.append(("type", node_type))
        encode = urllib.urlencode(param)
        if encode:
            url += "?"
            url += encode
        return self.core.list(url)
269088
function list (req, res, next) {
    // Resource chain
    var chain = db.get(name)

    // Remove q, _start, _end, ... from req.query to avoid filtering using those
    // parameters
    var _q = req.query._q
    var _offset = req.query._offset
    var _end = req.query._end
    var _page = req.query._page
    var _sort = req.query._sort
    var _limit = req.query._limit
    var _embed = req.query._embed
    var _expand = req.query._expand
    var _fields = req.query._fields
    var _filter = req.query._filter
    delete req.query._q
    delete req.query._offset
    delete req.query._end
    delete req.query._sort
    delete req.query._limit
    delete req.query._embed
    delete req.query._expand
    delete req.query._fields

    // Automatically delete query parameters that can't be found
    // in the database
    Object.keys(req.query).forEach(function (query) {
      var arr = db.get(name).value()
      for (var i in arr) {
        if (
          _.has(arr[i], query) ||
          query === 'callback' ||
          query === '_' ||
          query.indexOf('_lte') !== -1 ||
          query.indexOf('_gte') !== -1 ||
          query.indexOf('_ne') !== -1 ||
          query.indexOf('_like') !== -1
        ) return
      }
      delete req.query[query]
    })

    if (_q) {
      // Full-text search
      _q = _q.toLowerCase()

      chain = chain.filter(function (obj) {
        for (var key in obj) {
          var value = obj[key]
          if (db._.deepQuery(value, _q)) {
            return true
          }
        }
      })
    }

    var filterMapping = {}

    if (_filter) {
      var filters = _filter.split(',')
      filters.forEach(function (filter) {
        var filterParts = filter.split(operatorsRegex)
        if (filterParts.length !== 3) {
          return
        }
        var key = filterParts[0]
        var op = filterParts[1]
        var value = filterParts[2]

        if (!filterMapping[key + op]) {
          filterMapping[key + op] = {value: []}
        }

        filterMapping[key + op].value.push(value)
        filterMapping[key + op].op = op
      })
    }

    Object.keys(filterMapping).forEach(function (key) {
      var values = filterMapping[key].value

      chain = chain.filter(function (element) {
        return values
            .map(utils.toNative)
            .map(function (value) {
              var op = filterMapping[key].op
              var isDifferent = key.indexOf('!=') !== -1 // op === '!='
              var isRange = key.indexOf('<') !== -1 || key.indexOf('>') !== -1 || key.indexOf('<=') !== -1 || key.indexOf('>=') !== -1 //     op === '<' || op === '>' || op === '<=' || op === '>='
              var isLike = key.indexOf('~') !== -1 || key.indexOf('~=') !== -1 || key.indexOf('=~') !== -1  // op === '~' || op === "~=" || op === '=~'
              var isIn = key.indexOf('|=') !== -1
              var path = key.replace(operatorsRegex, '')
              var elementValue = _.get(element, path)

              if (isRange) {
                switch (op) {
                  case '<':
                    return elementValue < value
                  case '>':
                    return elementValue > value
                  case '<=':
                    return elementValue <= value
                  case '>=':
                    return elementValue >= value
                  default:
                    return false
                }
              } else if (isDifferent) {
                return value !== elementValue
              } else if (isLike) {
                return new RegExp(value, 'i').test(elementValue)
              } else if (isIn) {
                var inValues = value.toString().split('|')
                inValues = _.map(inValues, function (val) {
                  return utils.toNative(val)
                })
                if (Array.isArray(elementValue)) {
                  return _.intersection(elementValue, inValues).length > 0
                } else {
                  return _.includes(inValues, elementValue)
                }
              } else {
                return _.matchesProperty(path, value)(element)
              }
            }).reduce(function (a, b) {
              return a || b
            })
      })
    })

    // Sort
    if (_sort) {
      var sortsParams = _sort.split(',')

      var sortMapping = {}
      sortsParams.forEach(function (sortParam) {
        var order = sortParam[0] === '-' ? 'desc' : 'asc'
        var sortField = sortParam.substring(1)
        sortMapping[sortField] = order
      })

      chain = chain.orderBy(_.keys(sortMapping), _.values(sortMapping)) // TODO iteration order is not guaranteed
    }

    // Slice result
    if (_end || _limit || _page) {
      res.setHeader('X-Total-Count', chain.size())
      res.setHeader('Access-Control-Expose-Headers', 'X-Total-Count')
    }

    if (_page) {
      _page = parseInt(_page, 10)
      _page = _page >= 1 ? _page : 1
      _limit = parseInt(_limit, 10) || 10
      var page = utils.getPage(chain.value(), _page, _limit)
      var links = {}
      var fullURL = getFullURL(req)

      if (page.first) {
        links.first = fullURL.replace('page=' + page.current, 'page=' + page.first)
      }

      if (page.prev) {
        links.prev = fullURL.replace('page=' + page.current, 'page=' + page.prev)
      }

      if (page.next) {
        links.next = fullURL.replace('page=' + page.current, 'page=' + page.next)
      }

      if (page.last) {
        links.last = fullURL.replace('page=' + page.current, 'page=' + page.last)
      }

      res.links(links)
      chain = _.chain(page.items)
    } else if (_end) {
      _offset = parseInt(_offset, 10) || 0
      _end = parseInt(_end, 10)
      chain = chain.slice(_offset, _end)
    } else if (_limit) {
      _offset = parseInt(_offset, 10) || 0
      _limit = parseInt(_limit, 10)
      chain = chain.slice(_offset, _offset + _limit)
    }

    if (_fields) {
      chain = chain.map(function (element) {
        return _.pick(element, _fields.split(','))
      })
    }
    // embed and expand
    chain = chain
      .cloneDeep()
      .forEach(function (element) {
        embed(element, _embed)
        expand(element, _expand)
      })

    res.locals.data = chain.value()
    next()
  }
302390
def each_new_post_with_top_level_comments
      # TODO add keys assertion like in method above?
      json(:get, "/r/#{@subreddit}/new")["data"]["children"].each do |post|
        fail "unknown type post['kind']: #{post["kind"]}" unless post["kind"] == "t3"
        t = json :get, "/comments/#{post["data"]["id"]}", depth: 1, limit: 100500#, sort: "top"
        fail "smth weird about /comments/<id> response" unless t.size == 2
        yield post["data"], t[1]["data"]["children"].map{ |child|
          fail "unknown type child['kind']: #{child["kind"]}" unless child["kind"] == "t1"
          child["data"]
        }.to_enum
      end
    end
934739
def retrieve_posts(dir)
      site.posts.docs.concat(PostReader.new(site).read_posts(dir))
      site.posts.docs.concat(PostReader.new(site).read_drafts(dir)) if site.show_drafts
    end
1061799
def _list(self, uri, obj_class=None, body=None, return_raw=False,
            other_keys=None):
        
        if body:
            resp, resp_body = self.api.method_post(uri, body=body)
        else:
            resp, resp_body = self.api.method_get(uri)
        if return_raw:
            return (resp, resp_body)
        if obj_class is None:
            obj_class = self.resource_class

        data = self._data_from_response(resp_body)
        ret = [obj_class(self, res, loaded=False) for res in data if res]
        if other_keys:
            keys = utils.coerce_to_list(other_keys)
            other = [self._data_from_response(resp_body, key) for key in keys]
            return (ret, other)
        else:
            return ret
1050859
def items(self):
        
        content_type = ContentType.objects.get_for_model(Entry)
        return comments.get_model().objects.filter(
            content_type=content_type, is_public=True).order_by(
            '-submit_date')[:self.limit]
414873
def all_posts(self):
        """"""
        rev = self.db.get('site:rev')
        if int(rev) != self.revision:
            self.reload_site()

        return self._all_posts
652518
def _list(self, uri, obj_class=None, list_all=False):
        
        resp, resp_body = self._retry_get(uri)
        if obj_class is None:
            obj_class = self.resource_class

        data = resp_body[self.plural_response_key]
        ret = [obj_class(self, res, loaded=False)
                for res in data if res]
        self._reset_paging("domain", resp_body)
        if list_all:
            dom_paging = self._paging.get("domain", {})
            while dom_paging.get("next_uri"):
                next_uri = dom_paging.get("next_uri")
                ret.extend(self._list(uri=next_uri, obj_class=obj_class,
                        list_all=False))
        return ret
368964
function getCommentsList(comments) {
  if (!comments.body || !comments.headers) return;

  let pageInfo = getPage(comments.headers.link);
  let pageList = [];

  comments.body.forEach((item) => {
    pageList.push(getComments(item));
  });

  return {
    page: pageInfo,
    list: pageList
  }
}
708170
def get_pages_for_display(self):
        """"""

        # Start with an empty queryset, and expand as needed
        all_pages = Page.objects.none()

        if self.max_levels == 1:
            # If no additional sub-levels are needed, return empty queryset
            return all_pages

        for item in self.top_level_items:

            if item.link_page_id:
                # Fetch a 'branch' of suitable descendants for this item and
                # add to 'all_pages'
                page_depth = item.link_page.depth
                if(
                    item.allow_subnav and
                    page_depth >= settings.SECTION_ROOT_DEPTH
                ):
                    all_pages = all_pages | Page.objects.filter(
                        depth__gt=page_depth,
                        depth__lt=page_depth + self.max_levels,
                        path__startswith=item.link_page.path)

        # Filter the entire queryset to include only pages suitable for display
        all_pages = all_pages & self.get_base_page_queryset()

        # Return 'specific' page instances if required
        if self.use_specific == constants.USE_SPECIFIC_ALWAYS:
            return all_pages.specific()

        return all_pages
271737
def list(gandi, limit, step):
    """"""
    output_keys = ['id', 'type', 'step']

    options = {
        'step': step,
        'items_per_page': limit,
        'sort_by': 'date_created DESC'
    }

    result = gandi.oper.list(options)
    for num, oper in enumerate(reversed(result)):
        if num:
            gandi.separator_line()
        output_generic(gandi, oper, output_keys)

    return result
1259999
def list(self, limit=None, marker=None, name=None, visibility=None,
            member_status=None, owner=None, tag=None, status=None,
            size_min=None, size_max=None, sort_key=None, sort_dir=None,
            return_raw=False):
        
        uri = "/%s" % self.uri_base
        qs = utils.dict_to_qs(dict(limit=limit, marker=marker, name=name,
                visibility=visibility, member_status=member_status,
                owner=owner, tag=tag, status=status, size_min=size_min,
                size_max=size_max, sort_key=sort_key, sort_dir=sort_dir))
        if qs:
            uri = "%s?%s" % (uri, qs)
        return self._list(uri, return_raw=return_raw)