• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python normalized_hot.get_hot函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中r2.lib.normalized_hot.get_hot函数的典型用法代码示例。如果您正苦于以下问题:Python get_hot函数的具体用法?Python get_hot怎么用?Python get_hot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_hot函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: find_preview_links

def find_preview_links(sr):
    from r2.lib.normalized_hot import get_hot

    # try to find a link to use, otherwise give up and return
    links = get_hot(c.site)
    if not links:
        sr = Subreddit._by_name(g.default_sr)
        if sr:
            links = get_hot(sr)

    return links
开发者ID:vin,项目名称:reddit,代码行数:11,代码来源:cssfilter.py


示例2: find_preview_links

def find_preview_links(sr):
    from r2.lib.normalized_hot import get_hot

    # try to find a link to use, otherwise give up and return
    links = get_hot([c.site])
    if not links:
        links = get_hot(Subreddit.default_subreddits(ids=False))

    if links:
        links = links[:25]
        links = Link._by_fullname(links, data=True, return_dict=False)

    return links
开发者ID:BenHalberstam,项目名称:reddit,代码行数:13,代码来源:cssfilter.py


示例3: find_preview_links

def find_preview_links(sr):
    from r2.lib.normalized_hot import get_hot

    # try to find a link to use, otherwise give up and return
    links = get_hot([c.site],get_children=False)
    if not links:
        sr = Subsciteit._by_name(g.default_sr)
        if sr:
            links = get_hot([sr],get_children=False)

    if links:
        links = links[:25]
        links = Link._by_fullname(links, data=True, return_dict=False)

    return links
开发者ID:constantAmateur,项目名称:sciteit,代码行数:15,代码来源:cssfilter.py


示例4: query

    def query(self):
        #no need to worry when working from the cache
        if g.use_query_cache or isinstance(c.site, DefaultSR):
            self.fix_listing = False

        if isinstance(c.site, DefaultSR):
            if c.user_is_loggedin:
                srlimit = Subreddit.sr_limit
                over18 = c.user.has_subscribed and c.over18
            else:
                srlimit = g.num_default_reddits
                over18 = False

            sr_ids = Subreddit.user_subreddits(c.user,
                                               limit=srlimit,
                                               over18=over18)
            return normalized_hot(sr_ids)
        #if not using the query_cache we still want cached front pages
        elif (not g.use_query_cache
              and not isinstance(c.site, FakeSubreddit)
              and self.after is None
              and self.count == 0):
            return get_hot([c.site])
        else:
            return c.site.get_links('hot', 'all')
开发者ID:donslice,项目名称:reddit,代码行数:25,代码来源:listingcontroller.py


示例5: query

    def query(self):
        # no need to worry when working from the cache
        if g.use_query_cache or c.site == Default:
            self.fix_listing = False

        if c.site == Default:
            sr_ids = Subdigg.user_subreddits(c.user)
            return normalized_hot(sr_ids)
        # if not using the query_cache we still want cached front pages
        elif not g.use_query_cache and not isinstance(c.site, FakeSubdigg) and self.after is None and self.count == 0:
            return [l._fullname for l in get_hot(c.site)]
        else:
            return c.site.get_links("hot", "all")
开发者ID:kevinrose,项目名称:diggit,代码行数:13,代码来源:listingcontroller.py


示例6: query

    def query(self):
        #no need to worry when working from the cache
        if g.use_query_cache or c.site == Default:
            self.fix_listing = False

        if c.site == Default:
            sr_ids = Subreddit.user_subreddits(c.user)
            return normalized_hot(sr_ids)
        #if not using the query_cache we still want cached front pages
        elif (not g.use_query_cache
              and not isinstance(c.site, FakeSubreddit)
              and self.after is None
              and self.count == 0):
            return get_hot([c.site], only_fullnames = True)[0]
        else:
            return c.site.get_links('hot', 'all')
开发者ID:szimpatikus,项目名称:szimpatikus.hu,代码行数:16,代码来源:listingcontroller.py


示例7: query

    def query(self):
        #no need to worry when working from the cache
        if g.use_query_cache or c.site == Default:
            self.fix_listing = False

        if c.site == Default:
            sr_ids = Subreddit.user_subreddits(c.user,
                                               limit=(Subreddit.sr_limit
                                                      if c.user_is_loggedin
                                                      else g.num_default_reddits))
            return normalized_hot(sr_ids)
        #if not using the query_cache we still want cached front pages
        elif (not g.use_query_cache
              and not isinstance(c.site, FakeSubreddit)
              and self.after is None
              and self.count == 0):
            return get_hot([c.site])
        else:
            return c.site.get_links('hot', 'all')
开发者ID:codetripping,项目名称:reddit,代码行数:19,代码来源:listingcontroller.py


示例8: query

 def query(self):
     if c.site == Default:
         self.fix_listing = False
         self.builder_cls = IDBuilder
         user = c.user if c.user_is_loggedin else None
         sr_ids = Subreddit.user_subreddits(user)
         links = normalized_hot(sr_ids)
         return links
     elif (not isinstance(c.site, FakeSubreddit)
           and self.after is None
           and self.count == 0):
         self.builder_cls = IDBuilder
         links = [l._fullname for l in get_hot(c.site)]
         return links
     else:
         q = Link._query(sort = desc('_hot'), *c.site.query_rules())
         q._read_cache = True
         self.collect_stats = True
         return q
开发者ID:cmak,项目名称:reddit,代码行数:19,代码来源:listingcontroller.py


示例9: cached_organic_links

def cached_organic_links(user_id, langs):
    if user_id is None:
        sr_ids = Subreddit.default_subreddits()
    else:
        user = Account._byID(user_id, data=True)
        sr_ids = Subreddit.user_subreddits(user)

    sr_count = count.get_link_counts()

    #only use links from reddits that you're subscribed to
    link_names = filter(lambda n: sr_count[n][1] in sr_ids, sr_count.keys())
    link_names.sort(key = lambda n: sr_count[n][0])

    #potentially add a up and coming link
    if random.choice((True, False)) and sr_ids:
        sr = Subreddit._byID(random.choice(sr_ids))
        items = only_recent(get_hot(sr))
        if items:
            if len(items) == 1:
                new_item = items[0]
            else:
                new_item = random.choice(items[1:4])
            link_names.insert(0, new_item._fullname)

    # remove any that the user has acted on
    builder = IDBuilder(link_names,
                        skip = True, keep_fn = keep_link,
                        num = organic_length)
    link_names = [ x._fullname for x in builder.get_items()[0] ]

    #if not logged in, don't reset the count. if we did that we might get in a
    #cycle where the cache will return the same link over and over
    if user_id:
        update_pos(0)

    insert_promoted(link_names, sr_ids, user_id is not None)

    # remove any duplicates caused by insert_promoted if the user is logged in
    if user_id:
        link_names = list(UniqueIterator(link_names))

    return link_names
开发者ID:rajbot,项目名称:tikical,代码行数:42,代码来源:organic.py


示例10: cached_organic_links

def cached_organic_links(user_id, langs):
    if user_id is None:
        sr_ids = Subreddit.default_srs(langs, ids = True)
    else:
        user = Account._byID(user_id, data=True)
        sr_ids = Subreddit.user_subreddits(user)

    sr_count = count.get_link_counts()

    #only use links from reddits that you're subscribed to
    link_names = filter(lambda n: sr_count[n][1] in sr_ids, sr_count.keys())
    link_names.sort(key = lambda n: sr_count[n][0])

    #potentially add a up and coming link
    if random.choice((True, False)):
        sr = Subreddit._byID(random.choice(sr_ids))
        items = only_recent(get_hot(sr))
        if items:
            if len(items) == 1:
                new_item = items[0]
            else:
                new_item = random.choice(items[1:4])
            link_names.insert(0, new_item._fullname)

    # remove any that the user has acted on
    builder = IDBuilder(link_names,
                        skip = True, keep_fn = keep_link,
                        num = organic_length)
    link_names = [ x._fullname for x in builder.get_items()[0] ]

    calculation_key = str(time())
    update_pos(0, calculation_key)

    insert_promoted(link_names, sr_ids, user_id is not None)

    # remove any duplicates caused by insert_promoted
    ret = [ l for l in UniqueIterator(link_names) ]

    return (calculation_key, ret)
开发者ID:AndrewHay,项目名称:lesswrong,代码行数:39,代码来源:organic.py


示例11: cached_organic_links

def cached_organic_links(*sr_ids):
    sr_count = count.get_link_counts()
    #only use links from reddits that you're subscribed to
    link_names = filter(lambda n: sr_count[n][1] in sr_ids, sr_count.keys())
    link_names.sort(key = lambda n: sr_count[n][0])

    if not link_names and g.debug:
        q = All.get_links('new', 'all')
        q._limit = 100 # this decomposes to a _query
        link_names = [x._fullname for x in q if x.promoted is None]
        g.log.debug('Used inorganic links')

    #potentially add an up and coming link
    if random.choice((True, False)) and sr_ids:
        sr = Subreddit._byID(random.choice(sr_ids))
        fnames = get_hot([sr])
        if fnames:
            if len(fnames) == 1:
                new_item = fnames[0]
            else:
                new_item = random.choice(fnames[1:4])
            link_names.insert(0, new_item)

    return link_names
开发者ID:3river,项目名称:reddit,代码行数:24,代码来源:organic.py



注:本文中的r2.lib.normalized_hot.get_hot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python normalized_hot.normalized_hot函数代码示例发布时间:2022-05-26
下一篇:
Python mr_tools.mr_map函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap