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

Python db.has_trending函数代码示例

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

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



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

示例1: maybe_alert

    def maybe_alert(cls, project_id, message, group_id=None):
        now = timezone.now()
        manager = cls.objects
        # We only create an alert based on:
        # - an alert for the project hasn't been created in the last 30 minutes
        # - an alert for the event hasn't been created in the last 60 minutes

        # TODO: there is a race condition if we're calling this function for the same project
        if manager.filter(
                project=project_id, datetime__gte=now - timedelta(minutes=60)).exists():
            return

        if manager.filter(
                project=project_id, group=group_id,
                datetime__gte=now - timedelta(minutes=60)).exists():
            return

        alert = manager.create(
            project_id=project_id,
            group_id=group_id,
            datetime=now,
            message=message,
        )

        if not group_id and has_trending():
            # Capture the top 5 trending events at the time of this error
            related_groups = Group.objects.get_accelerated([project_id], minutes=MINUTE_NORMALIZATION)[:5]
            for group in related_groups:
                AlertRelatedGroup.objects.create(
                    group=group,
                    alert=alert,
                )

        return alert
开发者ID:blwidow,项目名称:sentry,代码行数:34,代码来源:models.py


示例2: group_list

def group_list(request, team, project):
    try:
        page = int(request.GET.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    response = _get_group_list(
        request=request,
        project=project,
    )

    # XXX: this is duplicate in _get_group_list
    sort_label = SORT_OPTIONS[response['sort']]

    has_realtime = page == 1

    return render_to_response('sentry/groups/group_list.html', {
        'team': project.team,
        'project': project,
        'from_date': response['date_from'],
        'to_date': response['date_to'],
        'date_type': response['date_type'],
        'has_realtime': has_realtime,
        'event_list': response['event_list'],
        'today': response['today'],
        'sort': response['sort'],
        'sort_label': sort_label,
        'filters': response['filters'],
        'SORT_OPTIONS': SORT_OPTIONS,
        'HAS_TRENDING': has_trending(),
    }, request)
开发者ID:dk-dev,项目名称:sentry,代码行数:31,代码来源:groups.py


示例3: get_group_trends

def get_group_trends(request, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if project:
        project_dict = {project.pk: project}
    else:
        project_dict = get_project_list(request.user)

    base_qs = Group.objects.filter(
        project__in=project_dict.keys(),
        status=0,
    )

    if has_trending():
        group_list = list(Group.objects.get_accelerated(base_qs, minutes=(
            minutes
        ))[:limit])
    else:
        cutoff = datetime.timedelta(minutes=minutes)
        cutoff_dt = timezone.now() - cutoff

        group_list = list(base_qs.filter(
            last_seen__gte=cutoff_dt
        ).order_by('-score')[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'

    return response
开发者ID:davidszotten,项目名称:sentry,代码行数:35,代码来源:api.py


示例4: group_list

def group_list(request, team, project):
    try:
        page = int(request.GET.get("p", 1))
    except (TypeError, ValueError):
        page = 1

    response = _get_group_list(request=request, project=project)

    # XXX: this is duplicate in _get_group_list
    sort_label = SORT_OPTIONS[response["sort"]]

    has_realtime = page == 1

    return render_to_response(
        "sentry/groups/group_list.html",
        {
            "team": project.team,
            "project": project,
            "from_date": response["date_from"],
            "to_date": response["date_to"],
            "date_type": response["date_type"],
            "has_realtime": has_realtime,
            "event_list": response["event_list"],
            "today": response["today"],
            "sort": response["sort"],
            "sort_label": sort_label,
            "filters": response["filters"],
            "SORT_OPTIONS": SORT_OPTIONS,
            "HAS_TRENDING": has_trending(),
        },
        request,
    )
开发者ID:berryp,项目名称:sentry,代码行数:32,代码来源:groups.py


示例5: get_group_trends

def get_group_trends(request, project=None):
    minutes = int(request.REQUEST.get("minutes", 15))
    limit = min(100, int(request.REQUEST.get("limit", 10)))

    if project:
        project_dict = {project.pk: project}
    else:
        project_dict = get_project_list(request.user)

    base_qs = Group.objects.filter(project__in=project_dict.keys(), status=0).order_by("-score")

    if has_trending():
        group_list = list(Group.objects.get_accelerated(base_qs, minutes=(minutes))[:limit])
    else:
        cutoff = datetime.timedelta(minutes=minutes)
        cutoff_dt = timezone.now() - cutoff

        group_list = list(base_qs.filter(last_seen__gte=cutoff_dt)[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = transform_groups(request, group_list, template="sentry/partial/_group_small.html")

    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"

    return response
开发者ID:nkabir,项目名称:sentry,代码行数:28,代码来源:api.py


示例6: test_get_accelerrated

 def test_get_accelerrated(self):
     if not has_trending():
         return
     group = Group.objects.from_kwargs(1, message='foo', checksum='a' * 32).group
     group_list = list(Group.objects.get_accelerated(Group.objects.all(), minutes=settings.MINUTE_NORMALIZATION)[0:100])
     self.assertEquals(len(group_list), 1)
     self.assertEquals(group_list[0], group)
开发者ID:NewAgeDev,项目名称:sentry,代码行数:7,代码来源:tests.py


示例7: get_group_trends

def get_group_trends(request, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if project:
        project_list = [project]
    else:
        project_list = get_project_list(request.user).values()

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = datetime.datetime.now() - cutoff

    base_qs = Group.objects.filter(
        project__in=project_list,
        status=0,
    ).select_related('project').order_by('-score')

    if has_trending():
        group_list = list(Group.objects.get_accelerated(base_qs, minutes=(
            (cutoff.days * 1440) + (cutoff.seconds * 60)
        ))[:limit])
    else:
        group_list = list(base_qs.filter(
            last_seen__gte=cutoff_dt
        )[:limit])

    data = transform_groups(request, group_list, template='sentry/partial/_group_small.html')

    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'

    return response
开发者ID:wingu,项目名称:sentry,代码行数:32,代码来源:api.py


示例8: get_group_trends

def get_group_trends(request, team=None, project=None):
    minutes = int(request.REQUEST.get("minutes", 15))
    limit = min(100, int(request.REQUEST.get("limit", 10)))

    if not team and project:
        project_list = [project]
    else:
        project_list = Project.objects.get_for_user(request.user, team=team)

    project_dict = dict((p.id, p) for p in project_list)

    base_qs = Group.objects.filter(project__in=project_list, status=0)

    if has_trending():
        group_list = list(Group.objects.get_accelerated(project_dict, base_qs, minutes=(minutes))[:limit])
    else:
        cutoff = datetime.timedelta(minutes=minutes)
        cutoff_dt = timezone.now() - cutoff

        group_list = list(
            base_qs.filter(status=STATUS_UNRESOLVED, last_seen__gte=cutoff_dt)
            .extra(select={"sort_value": "score"})
            .order_by("-score")[:limit]
        )

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response["Content-Type"] = "application/json"

    return response
开发者ID:rnoldo,项目名称:sentry,代码行数:34,代码来源:api.py


示例9: dashboard

def dashboard(request):
    project_list = get_project_list(request.user, key='slug')
    if len(project_list) == 0 and not request.user.is_authenticated():
        return HttpResponseRedirect(get_login_url())

    if project_list:
        cutoff = datetime.datetime.now() - datetime.timedelta(days=1)
        base_qs = Group.objects.filter(
            project__in=project_list.values(),
            status=0,
        ).select_related('project').order_by('-score')

        if has_trending():
            top_event_list = list(Group.objects.get_accelerated(base_qs, minutes=60 * 24)[:DASHBOARD_EVENTS])
        else:
            top_event_list = list(base_qs.filter(
                last_seen__gte=cutoff
            )[:DASHBOARD_EVENTS])

        new_event_list = list(base_qs.filter(
            active_at__gte=cutoff,
        )[:DASHBOARD_EVENTS])
    else:
        top_event_list = None
        new_event_list = None

    return render_to_response('sentry/dashboard.html', {
        'top_event_list': top_event_list,
        'new_event_list': new_event_list,
    }, request)
开发者ID:wingu,项目名称:sentry,代码行数:30,代码来源:generic.py


示例10: group_list

def group_list(request, project, view_id=None):
    try:
        page = int(request.GET.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseRedirect(reverse('sentry', args=[project.pk]))
    else:
        view = None

    filters, event_list = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    # XXX: this is duplicate in _get_group_list
    sort = request.GET.get('sort')
    if sort not in SORT_OPTIONS:
        sort = settings.DEFAULT_SORT_OPTION
    sort_label = SORT_OPTIONS[sort]

    since = request.GET.get('since')
    if since not in DATE_OPTIONS:
        since = settings.DEFAULT_DATE_OPTION
    since_label = DATE_OPTIONS[since]

    today = datetime.datetime.utcnow()

    has_realtime = page == 1

    return render_to_response('sentry/groups/group_list.html', {
        'project': project,

        'has_realtime': has_realtime,
        'event_list': event_list,
        'today': today,
        'sort': sort,
        'sort_label': sort_label,
        'since': since,
        'since_label': since_label,
        'filters': filters,
        'view': view,
        'SORT_OPTIONS': SORT_OPTIONS,
        'DATE_OPTIONS': DATE_OPTIONS,
        'HAS_TRENDING': has_trending(),
        'PAGE': 'dashboard',
    }, request)
开发者ID:bgyss,项目名称:sentry,代码行数:52,代码来源:groups.py


示例11: group_list

def group_list(request, project):
    try:
        page = int(request.GET.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    view_id = request.GET.get('view')
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=int(view_id))
        except View.DoesNotExist:
            return HttpResponseRedirect(reverse('sentry', args=[project.slug]))
    else:
        view = None

    response = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    # XXX: this is duplicate in _get_group_list
    sort_label = SORT_OPTIONS[response['sort']]

    has_realtime = page == 1

    return render_to_response('sentry/groups/group_list.html', {
        'project': project,
        'from_date': response['date_from'],
        'to_date': response['date_to'],
        'has_realtime': has_realtime,
        'event_list': response['event_list'],
        'today': response['today'],
        'sort': response['sort'],
        'sort_label': sort_label,
        'filters': response['filters'],
        'view': view,
        'SORT_OPTIONS': SORT_OPTIONS,
        'HAS_TRENDING': has_trending(),
        'PAGE': 'dashboard',
    }, request)
开发者ID:acdha,项目名称:sentry,代码行数:41,代码来源:groups.py


示例12: group_list

def group_list(request, project):
    try:
        page = int(request.GET.get("p", 1))
    except (TypeError, ValueError):
        page = 1

    view_id = request.GET.get("view")
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=int(view_id))
        except View.DoesNotExist:
            return HttpResponseRedirect(reverse("sentry", args=[project.slug]))
    else:
        view = None

    response = _get_group_list(request=request, project=project, view=view)

    # XXX: this is duplicate in _get_group_list
    sort_label = SORT_OPTIONS[response["sort"]]

    has_realtime = page == 1

    return render_to_response(
        "sentry/groups/group_list.html",
        {
            "project": project,
            "from_date": response["date_from"],
            "to_date": response["date_to"],
            "has_realtime": has_realtime,
            "event_list": response["event_list"],
            "today": response["today"],
            "sort": response["sort"],
            "sort_label": sort_label,
            "filters": response["filters"],
            "view": view,
            "SORT_OPTIONS": SORT_OPTIONS,
            "HAS_TRENDING": has_trending(),
            "PAGE": "dashboard",
        },
        request,
    )
开发者ID:davidszotten,项目名称:sentry,代码行数:41,代码来源:groups.py


示例13: has_trending

        event_list = event_list.filter(views=view)

    for filter_ in filters:
        try:
            if not filter_.is_set():
                continue
            event_list = filter_.get_query_set(event_list)
        except Exception, e:
            logger = logging.getLogger('sentry.filters')
            logger.exception('Error processing filter %r: %s', cls, e)

    sort = request.GET.get('sort')
    if sort not in SORT_OPTIONS:
        sort = settings.DEFAULT_SORT_OPTION

    if sort.startswith('accel_') and not has_trending():
        sort = settings.DEFAULT_SORT_OPTION

    engine = get_db_engine('default')
    if engine.startswith('sqlite'):
        sort_clause = SQLITE_SORT_CLAUSES.get(sort)
    elif engine.startswith('mysql'):
        sort_clause = MYSQL_SORT_CLAUSES.get(sort)
    else:
        sort_clause = SORT_CLAUSES.get(sort)

    if sort == 'tottime':
        event_list = event_list.filter(time_spent_count__gt=0)
    elif sort == 'avgtime':
        event_list = event_list.filter(time_spent_count__gt=0)
    elif sort.startswith('accel_'):
开发者ID:adamsc64,项目名称:sentry,代码行数:31,代码来源:groups.py


示例14: has_trending

                groupcountbyminute__date__gte=date_from, groupcountbyminute__date__lte=date_to
            )
        elif date_from:
            event_list = event_list.filter(last_seen__gte=date_from)
        elif date_to:
            event_list = event_list.filter(last_seen__lte=date_to)

    sort = request.GET.get("sort") or request.session.get("streamsort")
    if sort not in SORT_OPTIONS:
        sort = DEFAULT_SORT_OPTION

    # Save last sort in session
    if sort != request.session.get("streamsort"):
        request.session["streamsort"] = sort

    if sort.startswith("accel_") and not has_trending():
        sort = DEFAULT_SORT_OPTION

    engine = get_db_engine("default")
    if engine.startswith("sqlite"):
        score_clause = SQLITE_SORT_CLAUSES.get(sort)
        filter_clause = SQLITE_SCORE_CLAUSES.get(sort)
    elif engine.startswith("mysql"):
        score_clause = MYSQL_SORT_CLAUSES.get(sort)
        filter_clause = MYSQL_SCORE_CLAUSES.get(sort)
    elif engine.startswith("oracle"):
        score_clause = ORACLE_SORT_CLAUSES.get(sort)
        filter_clause = ORACLE_SCORE_CLAUSES.get(sort)
    elif engine in ("django_pytds", "sqlserver_ado", "sql_server.pyodbc"):
        score_clause = MSSQL_SORT_CLAUSES.get(sort)
        filter_clause = MSSQL_SCORE_CLAUSES.get(sort)
开发者ID:berryp,项目名称:sentry,代码行数:31,代码来源:groups.py


示例15: _get_group_list

def _get_group_list(request, project):
    filters = []
    for cls in get_filters(Group, project):
        try:
            filters.append(cls(request, project))
        except Exception as e:
            logger = logging.getLogger('sentry.filters')
            logger.exception('Error initializing filter %r: %s', cls, e)

    event_list = Group.objects
    if request.user.is_authenticated() and request.GET.get('bookmarks'):
        event_list = event_list.filter(
            bookmark_set__project=project,
            bookmark_set__user=request.user,
        )
    else:
        event_list = event_list.filter(project=project)

    for filter_ in filters:
        try:
            if not filter_.is_set():
                continue
            event_list = filter_.get_query_set(event_list)
        except Exception as e:
            logger = logging.getLogger('sentry.filters')
            logger.exception('Error processing filter %r: %s', cls, e)

    date_from = request.GET.get('df')
    time_from = request.GET.get('tf')
    date_to = request.GET.get('dt')
    time_to = request.GET.get('tt')
    date_type = request.GET.get('date_type')

    today = timezone.now()

    # date format is Y-m-d
    if any(x is not None for x in [date_from, time_from, date_to, time_to]):
        date_from, date_to = parse_date(date_from, time_from), parse_date(date_to, time_to)
    else:
        date_from = today - datetime.timedelta(days=5)
        date_to = None

    if date_type == 'first_seen':
        if date_from:
            event_list = event_list.filter(first_seen__gte=date_from)
        elif date_to:
            event_list = event_list.filter(first_seen__lte=date_to)
    else:
        if date_from and date_to:
            event_list = event_list.filter(
                groupcountbyminute__date__gte=date_from,
                groupcountbyminute__date__lte=date_to,
            )
        elif date_from:
            event_list = event_list.filter(last_seen__gte=date_from)
        elif date_to:
            event_list = event_list.filter(last_seen__lte=date_to)

    sort = request.GET.get('sort') or request.session.get('streamsort')
    if sort not in SORT_OPTIONS:
        sort = DEFAULT_SORT_OPTION

    # Save last sort in session
    if sort != request.session.get('streamsort'):
        request.session['streamsort'] = sort

    if sort.startswith('accel_') and not has_trending():
        sort = DEFAULT_SORT_OPTION

    engine = get_db_engine('default')
    if engine.startswith('sqlite'):
        score_clause = SQLITE_SORT_CLAUSES.get(sort)
        filter_clause = SQLITE_SCORE_CLAUSES.get(sort)
    elif engine.startswith('mysql'):
        score_clause = MYSQL_SORT_CLAUSES.get(sort)
        filter_clause = MYSQL_SCORE_CLAUSES.get(sort)
    elif engine.startswith('oracle'):
        score_clause = ORACLE_SORT_CLAUSES.get(sort)
        filter_clause = ORACLE_SCORE_CLAUSES.get(sort)
    elif engine in ('django_pytds', 'sqlserver_ado', 'sql_server.pyodbc'):
        score_clause = MSSQL_SORT_CLAUSES.get(sort)
        filter_clause = MSSQL_SCORE_CLAUSES.get(sort)
    else:
        score_clause = SORT_CLAUSES.get(sort)
        filter_clause = SCORE_CLAUSES.get(sort)

    # IMPORTANT: All filters must already be applied once we reach this point

    if sort == 'tottime':
        event_list = event_list.filter(time_spent_count__gt=0)
    elif sort == 'avgtime':
        event_list = event_list.filter(time_spent_count__gt=0)
    elif sort.startswith('accel_'):
        event_list = Group.objects.get_accelerated(
            [project.id], event_list, minutes=int(sort.split('_', 1)[1]))

    if score_clause:
        event_list = event_list.extra(
            select={'sort_value': score_clause},
        )
#.........这里部分代码省略.........
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:101,代码来源:groups.py


示例16: setUp

 def setUp(self):
     if not has_trending():
         raise SkipTest('This database does not support trends.')
开发者ID:acdha,项目名称:sentry,代码行数:3,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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