当前位置: 首页>>代码示例>>Python>>正文


Python models.MStatistics类代码示例

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


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

示例1: calculate_metrics

 def calculate_metrics(self):
     from apps.statistics.models import MStatistics
     
     return {
         'feed_loadtimes_avg_hour': MStatistics.get('latest_avg_time_taken'),
         'feeds_loaded_hour': MStatistics.get('latest_sites_loaded'),
     }
开发者ID:dosiecki,项目名称:NewsBlur,代码行数:7,代码来源:newsblur_loadtimes.py

示例2: run

 def run(self, feed_pks, **kwargs):
     from apps.rss_feeds.models import Feed
     from apps.statistics.models import MStatistics
     
     mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
     compute_scores = bool(mongodb_replication_lag < 10)
     
     options = {
         'fake': bool(MStatistics.get('fake_fetch')),
         'quick': float(MStatistics.get('quick_fetch', 0)),
         'compute_scores': compute_scores,
         'mongodb_replication_lag': mongodb_replication_lag,
     }
     
     if not isinstance(feed_pks, list):
         feed_pks = [feed_pks]
         
     for feed_pk in feed_pks:
         try:
             feed = Feed.get_by_id(feed_pk)
             if not feed:
                 raise Feed.DoesNotExist
             feed.update(**options)
         except Feed.DoesNotExist:
             logging.info(" ---> Feed doesn't exist: [%s]" % feed_pk)
开发者ID:0077cc,项目名称:NewsBlur,代码行数:25,代码来源:tasks.py

示例3: run

    def run(self, feed_pks, **kwargs):
        from apps.rss_feeds.models import Feed
        from apps.statistics.models import MStatistics
        r = redis.Redis(connection_pool=settings.REDIS_FEED_UPDATE_POOL)

        mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
        compute_scores = bool(mongodb_replication_lag < 10)
        
        profiler = DBProfilerMiddleware()
        profiler_activated = profiler.process_celery()
        if profiler_activated:
            mongo_middleware = MongoDumpMiddleware()
            mongo_middleware.process_celery(profiler)
            redis_middleware = RedisDumpMiddleware()
            redis_middleware.process_celery(profiler)
        
        options = {
            'quick': float(MStatistics.get('quick_fetch', 0)),
            'updates_off': MStatistics.get('updates_off', False),
            'compute_scores': compute_scores,
            'mongodb_replication_lag': mongodb_replication_lag,
        }
        
        if not isinstance(feed_pks, list):
            feed_pks = [feed_pks]
            
        for feed_pk in feed_pks:
            feed = Feed.get_by_id(feed_pk)
            if not feed or feed.pk != int(feed_pk):
                logging.info(" ---> ~FRRemoving feed_id %s from tasked_feeds queue, points to %s..." % (feed_pk, feed and feed.pk))
                r.zrem('tasked_feeds', feed_pk)
            if feed:
                feed.update(**options)
                if profiler_activated: profiler.process_celery_finished()
开发者ID:bodegard,项目名称:NewsBlur,代码行数:34,代码来源:tasks.py

示例4: run

    def run(self, feed_pks, **kwargs):
        from apps.rss_feeds.models import Feed
        from apps.statistics.models import MStatistics
        r = redis.Redis(connection_pool=settings.REDIS_FEED_POOL)

        mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
        compute_scores = bool(mongodb_replication_lag < 10)
        
        options = {
            'quick': float(MStatistics.get('quick_fetch', 0)),
            'updates_off': MStatistics.get('updates_off', False),
            'compute_scores': compute_scores,
            'mongodb_replication_lag': mongodb_replication_lag,
        }
        
        if not isinstance(feed_pks, list):
            feed_pks = [feed_pks]
            
        for feed_pk in feed_pks:
            feed = Feed.get_by_id(feed_pk)
            if not feed or feed.pk != int(feed_pk):
                logging.info(" ---> ~FRRemoving feed_id %s from tasked_feeds queue, points to %s..." % (feed_pk, feed and feed.pk))
                r.zrem('tasked_feeds', feed_pk)
            if feed:
                feed.update(**options)
开发者ID:Alexpcole,项目名称:NewsBlur,代码行数:25,代码来源:tasks.py

示例5: calculate_metrics

 def calculate_metrics(self):
     from apps.statistics.models import MStatistics
     
     return {
         'sql_avg': MStatistics.get('latest_sql_avg'),
         'mongo_avg': MStatistics.get('latest_mongo_avg'),
         'redis_avg': MStatistics.get('latest_redis_avg'),
     }
开发者ID:76,项目名称:NewsBlur,代码行数:8,代码来源:newsblur_dbtimes.py

示例6: handle

 def handle(self, *args, **options):
     if options['daemonize']:
         daemonize()
     
     settings.LOG_TO_STREAM = True
     now = datetime.datetime.utcnow()
     
     if options['skip']:
         feeds = Feed.objects.filter(next_scheduled_update__lte=now,
                                     average_stories_per_month__lt=options['skip'],
                                     active=True)
         print " ---> Skipping %s feeds" % feeds.count()
         for feed in feeds:
             feed.set_next_scheduled_update()
             print '.',
         return
         
     socket.setdefaulttimeout(options['timeout'])
     if options['force']:
         feeds = Feed.objects.all()
     elif options['username']:
         feeds = Feed.objects.filter(subscribers__user=User.objects.get(username=options['username']))
     elif options['feed']:
         feeds = Feed.objects.filter(pk=options['feed'])
     else:
         feeds = Feed.objects.filter(next_scheduled_update__lte=now, active=True)
     
     feeds = feeds.order_by('?')
     
     for f in feeds:
         f.set_next_scheduled_update()
     
     num_workers = min(len(feeds), options['workerthreads'])
     if options['single_threaded']:
         num_workers = 1
     
     options['compute_scores'] = True
     options['quick'] = float(MStatistics.get('quick_fetch', 0))
     options['updates_off'] = MStatistics.get('updates_off', False)
     
     disp = feed_fetcher.Dispatcher(options, num_workers)        
     
     feeds_queue = []
     for _ in range(num_workers):
         feeds_queue.append([])
     
     i = 0
     for feed in feeds:
         feeds_queue[i%num_workers].append(feed.pk)
         i += 1
     disp.add_jobs(feeds_queue, i)
     
     django.db.connection.close()
     
     print " ---> Fetching %s feeds..." % feeds.count()
     disp.run_jobs()
开发者ID:1059232202,项目名称:NewsBlur,代码行数:56,代码来源:refresh_feeds.py

示例7: run

    def run(self, feed_pks, **kwargs):
        from apps.rss_feeds.models import Feed
        from apps.statistics.models import MStatistics

        options = {"fake": bool(MStatistics.get("fake_fetch")), "quick": float(MStatistics.get("quick_fetch", 0))}

        if not isinstance(feed_pks, list):
            feed_pks = [feed_pks]

        for feed_pk in feed_pks:
            try:
                feed = Feed.objects.get(pk=feed_pk)
                feed.update(options=options)
            except Feed.DoesNotExist:
                logging.info(" ---> Feed doesn't exist: [%s]" % feed_pk)
开发者ID:codesburner,项目名称:NewsBlur,代码行数:15,代码来源:tasks.py

示例8: calculate_metrics

 def calculate_metrics(self):
     from apps.statistics.models import MStatistics
     statistics = MStatistics.all()
 
     return {
         'feed_success': statistics['feeds_fetched'],
     }
开发者ID:200895045,项目名称:NewsBlur,代码行数:7,代码来源:newsblur_errors.py

示例9: dashboard_graphs

def dashboard_graphs(request):
    statistics = MStatistics.all()
    return render_to_response(
        "statistics/render_statistics_graphs.xhtml",
        {"statistics": statistics},
        context_instance=RequestContext(request),
    )
开发者ID:Chorior,项目名称:NewsBlur,代码行数:7,代码来源:views.py

示例10: run

 def run(self, feed_id, xml, **kwargs):
     from apps.rss_feeds.models import Feed
     from apps.statistics.models import MStatistics
     
     mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
     compute_scores = bool(mongodb_replication_lag < 60)
     
     options = {
         'feed_xml': xml,
         'compute_scores': compute_scores,
         'mongodb_replication_lag': mongodb_replication_lag,
     }
     feed = Feed.get_by_id(feed_id)
     feed.update(options=options)
开发者ID:imageoptimiser,项目名称:NewsBlur,代码行数:14,代码来源:tasks.py

示例11: run

    def run(self, feed_pks, **kwargs):
        from apps.rss_feeds.models import Feed
        from apps.statistics.models import MStatistics

        mongodb_replication_lag = int(MStatistics.get("mongodb_replication_lag", 0))
        compute_scores = bool(mongodb_replication_lag < 10)

        options = {
            "fake": bool(MStatistics.get("fake_fetch")),
            "quick": float(MStatistics.get("quick_fetch", 0)),
            "compute_scores": compute_scores,
            "mongodb_replication_lag": mongodb_replication_lag,
        }

        if not isinstance(feed_pks, list):
            feed_pks = [feed_pks]

        for feed_pk in feed_pks:
            try:
                feed = Feed.get_by_id(feed_pk)
                feed.update(**options)
            except Feed.DoesNotExist:
                logging.info(" ---> Feed doesn't exist: [%s]" % feed_pk)
开发者ID:rogeliozarate,项目名称:NewsBlur,代码行数:23,代码来源:tasks.py

示例12: run

 def run(self, feed_pks, **kwargs):
     from apps.rss_feeds.models import Feed
     from apps.statistics.models import MStatistics
     
     fake = bool(MStatistics.get('fake_fetch'))
     
     if not isinstance(feed_pks, list):
         feed_pks = [feed_pks]
         
     for feed_pk in feed_pks:
         try:
             feed = Feed.objects.get(pk=feed_pk)
             feed.update(fake=fake)
         except Feed.DoesNotExist:
             logging.info(" ---> Feed doesn't exist: [%s]" % feed_pk)
开发者ID:atiw003,项目名称:NewsBlur,代码行数:15,代码来源:tasks.py

示例13: index

def index(request):
    if request.method == "POST":
        if request.POST['submit'] == 'login':
            login_form = LoginForm(request.POST, prefix='login')
            signup_form = SignupForm(prefix='signup')
        else:
            login_form = LoginForm(prefix='login')
            signup_form = SignupForm(request.POST, prefix='signup')
    else:
        login_form = LoginForm(prefix='login')
        signup_form = SignupForm(prefix='signup')
    
    user = get_user(request)
    features = Feature.objects.all()[:3]
    feature_form = None
    if request.user.is_staff:
        feature_form = FeatureForm()

    feed_count = 0
    active_count = 0
    train_count = 0
    if request.user.is_authenticated():
        feed_count = UserSubscription.objects.filter(user=request.user).count()
        active_count = UserSubscription.objects.filter(user=request.user, active=True).count()
        train_count = UserSubscription.objects.filter(user=request.user, active=True, is_trained=False, feed__stories_last_month__gte=1).count()
    
    now = datetime.datetime.now()
    recommended_feeds = RecommendedFeed.objects.filter(is_public=True, approved_date__lte=now).select_related('feed')[:2]
    # recommended_feed_feedback = RecommendedFeedUserFeedback.objects.filter(recommendation=recommended_feed)

    statistics = MStatistics.all()
    howitworks_page = 0 # random.randint(0, 5)
    return render_to_response('reader/feeds.xhtml', {
        'user_profile': user.profile,
        'login_form': login_form,
        'signup_form': signup_form,
        'feature_form': feature_form,
        'features': features,
        'start_import_from_google_reader': request.session.get('import_from_google_reader', False),
        'howitworks_page': howitworks_page,
        'feed_count': feed_count,
        'active_count': active_count,
        'train_count': active_count - train_count,
        'account_images': range(1, 4),
        'recommended_feeds': recommended_feeds,
        'statistics': statistics,
        # 'recommended_feed_feedback': recommended_feed_feedback,
    }, context_instance=RequestContext(request))
开发者ID:adamjernst,项目名称:NewsBlur,代码行数:48,代码来源:views.py

示例14: welcome

def welcome(request, **kwargs):
    user = get_user(request)
    statistics = MStatistics.all()
    social_profile = MSocialProfile.get_user(user.pk)

    if request.method == "POST":
        pass
    else:
        login_form = LoginForm(prefix='login')
        signup_form = SignupForm(prefix='signup')

    return {
        'user_profile': hasattr(user, 'profile') and user.profile,
        'login_form': login_form,
        'signup_form': signup_form,
        'statistics': statistics,
        'social_profile': social_profile,
        'post_request': request.method == 'POST'
    }, "reader/welcome.xhtml"
开发者ID:buyongji,项目名称:NewsBlur,代码行数:19,代码来源:views.py

示例15: index

def index(request):
    if request.method == "POST":
        if request.POST['submit'] == 'login':
            login_form  = LoginForm(request.POST, prefix='login')
            signup_form = SignupForm(prefix='signup')
        else:
            login_form  = LoginForm(prefix='login')
            signup_form = SignupForm(request.POST, prefix='signup')
    else:
        login_form  = LoginForm(prefix='login')
        signup_form = SignupForm(prefix='signup')
    
    user         = get_user(request)
    authed       = request.user.is_authenticated()
    features     = Feature.objects.all()[:3]
    feature_form = FeatureForm() if request.user.is_staff else None
    feed_count   = UserSubscription.objects.filter(user=request.user).count() if authed else 0
    active_count = UserSubscription.objects.filter(user=request.user, active=True).count() if authed else 0
    train_count  = UserSubscription.objects.filter(user=request.user, active=True, is_trained=False, feed__stories_last_month__gte=1).count() if authed else 0
    recommended_feeds = RecommendedFeed.objects.filter(is_public=True, approved_date__lte=datetime.datetime.now()).select_related('feed')[:2]
    unmoderated_feeds = RecommendedFeed.objects.filter(is_public=False, declined_date__isnull=True).select_related('feed')[:2]
    statistics   = MStatistics.all()
    feedbacks    = MFeedback.all()
    start_import_from_google_reader = request.session.get('import_from_google_reader', False)
    if start_import_from_google_reader:
        del request.session['import_from_google_reader']

    return render_to_response('reader/feeds.xhtml', {
        'user_profile'      : hasattr(user, 'profile') and user.profile,
        'login_form'        : login_form,
        'signup_form'       : signup_form,
        'feature_form'      : feature_form,
        'features'          : features,
        'feed_count'        : feed_count,
        'active_count'      : active_count,
        'train_count'       : active_count - train_count,
        'account_images'    : range(1, 4),
        'recommended_feeds' : recommended_feeds,
        'unmoderated_feeds' : unmoderated_feeds,
        'statistics'        : statistics,
        'feedbacks'         : feedbacks,
        'start_import_from_google_reader': start_import_from_google_reader,
    }, context_instance=RequestContext(request))
开发者ID:mrcrabby,项目名称:NewsBlur,代码行数:43,代码来源:views.py


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