Query posts, outdate.
488238
def query_dated(num=8, kind='1'):
        '''
        
        '''
        return TabPost.select().where(
            TabPost.kind == kind
        ).order_by(
            TabPost.time_update.asc()
        ).limit(num)
957043
async def filter_new_posts(self, source_id, post_ids):
        """"""
        new_ids = []
        try:
            db_client = self._db
            posts_in_db = await db_client.get_known_posts(source_id, post_ids)
            new_ids = [p for p in post_ids if p not in posts_in_db]
        except Exception as exc:
            logger.error("Error when filtering for new posts {} {}".format(source_id, post_ids))
            logger.exception(exc)
        return new_ids
643756
def p_recent(self, kind, cur_p='', with_catalog=True, with_date=True):
        '''
        
        '''
        if cur_p == '':
            current_page_number = 1
        else:
            current_page_number = int(cur_p)

        current_page_number = 1 if current_page_number < 1 else current_page_number

        pager_num = int(MPost.total_number(kind) / CMS_CFG['list_num'])
        kwd = {
            'pager': '',
            'title': 'Recent posts.',
            'with_catalog': with_catalog,
            'with_date': with_date,
            'kind': kind,
            'current_page': current_page_number,
            'post_count': MPost.get_counts(),
            'router': config.router_post[kind],
        }
        self.render('admin/post_ajax/post_list.html',
                    kwd=kwd,
                    view=MPost.query_recent(num=20, kind=kind),
                    infos=MPost.query_pager_by_slug(
                        kind=kind,
                        current_page_num=current_page_number
                    ),
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg=CMS_CFG, )
10814
def get_last(postid, limit=10):
        '''
        
        '''
        recs = TabPostHist.select().where(
            TabPostHist.post_id == postid
        ).order_by(TabPostHist.time_update.desc()).limit(limit)
        if recs.count():
            return recs.get()
        return None
1156306
def query_by_postid(postid, limit=5):
        '''
        
        '''
        recs = TabPostHist.select().where(
            TabPostHist.post_id == postid
        ).order_by(
            TabPostHist.time_update.desc()
        ).limit(limit)
        return recs
120068
public function posts()
    {
        $withTrashed = config('forum.preferences.display_trashed_posts') || Gate::allows('viewTrashedPosts');
        $query = $this->hasMany(Post::class);
        return $withTrashed ? $query->withTrashed() : $query;
    }
939873
def query(cls, resources, time_range, query, resource_type, sampler):
        """"""
        if not isinstance(resources, (list, tuple)):
            resources = [resources]

        now = time.time()
        start_utc = datetime.utcfromtimestamp(now - time_range)
        end_utc = datetime.utcfromtimestamp(now)
        date_format = '%Y-%m-%d %H:%M:%S'
        start = start_utc.strftime(date_format)
        end = end_utc.strftime(date_format)
        query = {'start': start,
                 'end': end,
                 'query': query,
                 'resource_id': resources,
                 'resource_type': resource_type,
                 'sampler': sampler}
        return cls.call('hosting.metric.query', query)
106845
def posts(quantity=0)
      query = "SELECT * FROM meme.posts(#{quantity}) WHERE owner_guid='#{self.guid}';"
      parse = Request.parse(query)
      if parse
        results = parse['query']['results']
        results.nil? ? nil : results['post'].map {|m| Post.new(m)}
      else
        parse.error!
      end
    end
858171
def run_object_query(client, base_object_query, start_record, limit_to,
                     verbose=False):
    """"""
    if verbose:
        print("[start: %d limit: %d]" % (start_record, limit_to))
    start = datetime.datetime.now()
    result = client.execute_object_query(
        object_query=base_object_query,
        start_record=start_record,
        limit_to=limit_to)
    end = datetime.datetime.now()
    if verbose:
        print("[%s - %s]" % (start, end))
    return result
746315
def _get_last_entries(db, qty):
    """"""
    doc_ids = [post.doc_id for post in db.posts.all()]
    doc_ids = sorted(doc_ids, reverse=True)
    # bug: here we shoud only render doc_ids[:qty]
    # but we can't use mtimes for sorting. We'll need to add ptime for the
    # database (publish time)
    entries = [Entry(os.path.join(CONFIG['content_root'],
                     db.posts.get(doc_id=doc_id)['filename']), doc_id)
               for doc_id in doc_ids]
    # return _sort_entries(entries)[:qty]
    entries.sort(key=operator.attrgetter('date'), reverse=True)
    return entries[:qty], entries
866079
def get_all(kind='2'):
        '''
        
        '''
        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.valid == 1)
        ).order_by(
            TabPost.time_update.desc()
        )
228066
def update_where(self, res, depth=0, since=None, **kwargs):
        ""
        fetch = lambda: self._fetcher.fetch_all_latest(res, 0, kwargs, since=since)
        self._update(res, fetch, depth)
291173
async def on_date(self, date: datetime.date) -> dict:
        """"""
        return await self._request(
            'get', 'dailystats/{0}'.format(date.strftime('%Y-%m-%d')))
359269
def query_insert(self, direction='max'):
        
        if direction == 'min':
            return Layer.objects.aggregate(
                Min('last_updated'))['last_updated__min'].strftime('%Y-%m-%dT%H:%M:%SZ')
        return self._get_repo_filter(Layer.objects).aggregate(
            Max('last_updated'))['last_updated__max'].strftime('%Y-%m-%dT%H:%M:%SZ')
808447
function query_posts()
   	{
   		// vars
   		$r = array(
   			'next_page_exists' => 1,
   			'html' => ''
   		);
   		
   		
   		// options
		$options = array(
			'post_type'					=>	'all',
			'taxonomy'					=>	'all',
			'posts_per_page'			=>	10,
			'paged'						=>	1,
			'orderby'					=>	'title',
			'order'						=>	'ASC',
			'post_status'				=>	'any',
			'suppress_filters'			=>	false,
			's'							=>	'',
			'lang'						=>	false,
			'update_post_meta_cache'	=>	false,
			'field_key'					=>	'',
			'nonce'						=>	'',
			'ancestor'					=>	false,
		);
		
		$options = array_merge( $options, $_POST );
		
		
		// validate
		if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
		{
			die();
		}
		
		
		// WPML
		if( $options['lang'] )
		{
			global $sitepress;
			
			if( !empty($sitepress) )
			{
				$sitepress->switch_lang( $options['lang'] );
			}
		}
		
		
		// convert types
		$options['post_type'] = explode(',', $options['post_type']);
		$options['taxonomy'] = explode(',', $options['taxonomy']);
		
		
		// load all post types by default
		if( in_array('all', $options['post_type']) )
		{
			$options['post_type'] = apply_filters('acf/get_post_types', array());
		}
		
		
		// attachment doesn't work if it is the only item in an array???
		if( is_array($options['post_type']) && count($options['post_type']) == 1 )
		{
			$options['post_type'] = $options['post_type'][0];
		}
		
		
		// create tax queries
		if( ! in_array('all', $options['taxonomy']) )
		{
			// vars
			$taxonomies = array();
			$options['tax_query'] = array();
			
			foreach( $options['taxonomy'] as $v )
			{
				
				// find term (find taxonomy!)
				// $term = array( 0 => $taxonomy, 1 => $term_id )
				$term = explode(':', $v); 
				
				
				// validate
				if( !is_array($term) || !isset($term[1]) )
				{
					continue;
				}
				
				
				// add to tax array
				$taxonomies[ $term[0] ][] = $term[1];
				
			}
			
			
			// now create the tax queries
			foreach( $taxonomies as $k => $v )
			{
				$options['tax_query'][] = array(
					'taxonomy' => $k,
					'field' => 'id',
					'terms' => $v,
				);
			}
		}
		
		unset( $options['taxonomy'] );
		
		
		// load field
		$field = array();
		if( $options['ancestor'] )
		{
			$ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] );
			$field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor );
		}
		else
		{
			$field = apply_filters('acf/load_field', array(), $options['field_key'] );
		}
		
		
		// get the post from which this field is rendered on
		$the_post = get_post( $options['post_id'] );
		
		
		// filters
		$options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post);
		$options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post );
		$options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post );
		
		
		// query
		$wp_query = new WP_Query( $options );

		
		// global
		global $post;
		
		
		// loop
		while( $wp_query->have_posts() ) {
			
			$wp_query->the_post();
			
			
			// get title
			$title = $this->get_result($post, $field, $the_post, $options);
			
			
			// update html
			$r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title .  '<span class="acf-button-add"></span></a></li>';
				
		}
		
		
		// next page
		if( (int)$options['paged'] >= $wp_query->max_num_pages ) {
			
			$r['next_page_exists'] = 0;
			
		}
		
		
		// reset
		wp_reset_postdata();
		
		
		// return JSON
		echo json_encode( $r );
		
		die();
			
	}
1155716
def posts(self):
        """"""
        rev = int(self.db.get('site:rev'))
        if rev != self.revision:
            self.reload_site()

        return self._posts
986917
@SuppressWarnings("unchecked")
    @Override
    public <R> R query(TemporalQuery<R> query) {
        if (query == TemporalQueries.chronology()) {
            return (R) getChronology();
        } else if (query == TemporalQueries.precision()) {
            return (R) NANOS;
        } else if (query == TemporalQueries.localDate()) {
            return (R) LocalDate.ofEpochDay(toLocalDate().toEpochDay());
        } else if (query == TemporalQueries.localTime()) {
            return (R) toLocalTime();
        } else if (query == TemporalQueries.zone() || query == TemporalQueries.zoneId() || query == TemporalQueries.offset()) {
            return null;
        }
        return super.query(query);
    }