Query post2tag by certain post.
180008
def query_by_entity_uid(idd, kind=''):
        '''
        
        '''

        if kind == '':
            return TabPost2Tag.select(
                TabPost2Tag,
                TabTag.slug.alias('tag_slug'),
                TabTag.name.alias('tag_name')
            ).join(
                TabTag, on=(TabPost2Tag.tag_id == TabTag.uid)
            ).where(
                (TabPost2Tag.post_id == idd) &
                (TabTag.kind != 'z')
            ).order_by(
                TabPost2Tag.order
            )
        return TabPost2Tag.select(
            TabPost2Tag,
            TabTag.slug.alias('tag_slug'),
            TabTag.name.alias('tag_name')
        ).join(TabTag, on=(TabPost2Tag.tag_id == TabTag.uid)).where(
            (TabTag.kind == kind) &
            (TabPost2Tag.post_id == idd)
        ).order_by(
            TabPost2Tag.order
        )
959130
public Query setHighlightingTags(String preTag, String postTag) {
    this.highlightPreTag = preTag;
    this.highlightPostTag = postTag;
    return this;
  }
537286
public function activeByTag($tag, $per_page)
	{
		$per_page = is_numeric($per_page) ? $per_page : 5;

		return Post::with(array('tags', 'user'))
			->select('posts.*')
			->join('tags', 'posts.id', '=', 'tags.post_id')
			->where('tags.tag', '=', $tag)
			->orderBy('posts.publish_date', 'desc')
			->where('posts.active', 1)
			->where('posts.publish_date', '<=', new DateTime)
			->distinct()
			->paginate($per_page);
	}
1052537
def custom_filter_tags(self, value, search):
        """"""
        if not isinstance(value, list):
            value = value.split(',')

        filters = [Q('match', **{'tags': item}) for item in value]
        search = search.query('bool', must=filters)

        return search
977414
function postSetTags(post_id, tags, cb) {
  var ids = _.pluck(tags, 'id')
    , q1 = 'DELETE FROM posts_tags WHERE post_id = $1'
    , q2 = 'INSERT INTO posts_tags (post_id, tag_id) VALUES ' +
    ids.map(function(id) {
      return '(' + post_id + ',' + id + ')';
    }).join(', ');

  db.getClient(function(err, client, done) {
    client.query(q1, [post_id], function(err, r) {
      if(err) { return cb(err); }
      client.query(q2, function(err, r) {
        if(err) {
          cb(err);
          done(err);
        } else {
          cb(null, r.rowCount);
          done();
        }
      });
    });
  });
}
984274
def _match_tag_regex(self, event_tag, search_tag):
        '''
        
        '''
        return self.cache_regex.get(search_tag).search(event_tag) is not None
367088
function(tag) {
    var posts = [];
    for (var key in this.posts) {
      if (this.posts[key].tags && this.posts[key].tags.indexOf(tag) !== -1) {
        posts.push(this.posts[key]);
      }
    }
    return posts;
  }
798138
def by_tag_id(self,tag_id):
		'''

		'''
		query = meta.Session.query(TagSemanticTag).filter(TagSemanticTag.tag_id==tag_id)
		return query.first()
502069
def __query_with_label(cat_id_arr, label=None, num=8, kind='1'):
        '''
        
        '''
        return TabPost.select().join(
            TabPost2Tag,
            on=(TabPost.uid == TabPost2Tag.post_id)
        ).where(
            (TabPost.kind == kind) &
            (TabPost2Tag.tag_id << cat_id_arr) &  # the "<<" operator signifies an "IN" query
            (TabPost.extinfo['def_tag_arr'].contains(label))
        ).order_by(
            TabPost.time_create.desc()
        ).limit(num)
518429
def _get_tag_query_tag(self, sampler, wmi_obj, tag_query):
        
        self.log.debug(
            u"`tag_queries` parameter found."
            " wmi_object={wmi_obj} - query={tag_query}".format(wmi_obj=wmi_obj, tag_query=tag_query)
        )

        # Extract query information
        target_class, target_property, filters = self._format_tag_query(sampler, wmi_obj, tag_query)

        # Create a specific sampler
        tag_query_sampler = WMISampler(self.log, target_class, [target_property], filters=filters, **sampler.connection)

        tag_query_sampler.sample()

        # Extract tag
        self._raise_on_invalid_tag_query_result(tag_query_sampler, wmi_obj, tag_query)

        link_value = str(tag_query_sampler[0][target_property]).lower()

        tag = "{tag_name}:{tag_value}".format(tag_name=target_property.lower(), tag_value="_".join(link_value.split()))

        self.log.debug(u"Extracted `tag_queries` tag: '{tag}'".format(tag=tag))
        return tag
194568
def filter(self):  # noqa A001
        """"""

        return [tag for tag in self.get_contents(self.tag) if not self.is_navigable_string(tag) and self.match(tag)]
415353
public List<Post> tagged(String tag, Map<String, ?> options) {
        if (options == null) {
            options = Collections.emptyMap();
        }
        Map<String, Object> soptions = JumblrClient.safeOptionMap(options);
        soptions.put("api_key", apiKey);
        soptions.put("tag", tag);
        return requestBuilder.get("/tagged", soptions).getTaggedPosts();
    }
867525
def __get_by_info(post_id, catalog_id):
        '''
        
        '''
        recs = TabPost2Tag.select().where(
            (TabPost2Tag.post_id == post_id) &
            (TabPost2Tag.tag_id == catalog_id)
        )

        if recs.count() == 1:
            return recs.get()
        elif recs.count() > 1:
            # return the first one, and delete others.
            out_rec = None
            for rec in recs:
                if out_rec:
                    entry = TabPost2Tag.delete().where(
                        TabPost2Tag.uid == rec.uid
                    )
                    entry.execute()
                else:
                    out_rec = rec
            return out_rec
        return None
890976
def select_one(self, tag):
        """"""

        tags = self.select(tag, limit=1)
        return tags[0] if tags else None
761495
def lookup_tag(name):
    """"""
    return next((_TAGS[t] for t in _TAGS if t == name),
                DmapTag(_read_unknown, 'unknown tag'))
303360
def get_by_slug(tag_slug):
        '''
        
        '''
        label_recs = TabTag.select().where(TabTag.slug == tag_slug)
        return label_recs.get() if label_recs else False
663790
def call(self, tag_name: str, *args, **kwargs):
        """"""
        if hasattr(self, tag_name):
            getattr(self, tag_name)(*args, **kwargs)