本文整理汇总了Python中sentry.models.Group.calculate_score方法的典型用法代码示例。如果您正苦于以下问题:Python Group.calculate_score方法的具体用法?Python Group.calculate_score怎么用?Python Group.calculate_score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.models.Group
的用法示例。
在下文中一共展示了Group.calculate_score方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_group_backfill_attributes
# 需要导入模块: from sentry.models import Group [as 别名]
# 或者: from sentry.models.Group import calculate_score [as 别名]
def test_get_group_backfill_attributes(self):
now = datetime(2017, 5, 3, 6, 6, 6, tzinfo=pytz.utc)
assert get_group_backfill_attributes(
get_caches(),
Group(
active_at=now,
first_seen=now,
last_seen=now,
platform='javascript',
message='Hello from JavaScript',
level=logging.INFO,
score=Group.calculate_score(3, now),
logger='javascript',
times_seen=1,
first_release=None,
culprit='',
data={
'type': 'default',
'last_received': to_timestamp(now),
'metadata': {},
},
),
[
Event(
platform='python',
message='Hello from Python',
datetime=now - timedelta(hours=1),
data={
'type': 'default',
'metadata': {},
'tags': [
['level', 'error'],
['logger', 'python'],
],
},
),
Event(
platform='java',
message='Hello from Java',
datetime=now - timedelta(hours=2),
data={
'type': 'default',
'metadata': {},
'tags': [
['level', 'debug'],
['logger', 'java'],
],
},
),
],
) == {
'active_at': now - timedelta(hours=2),
'first_seen': now - timedelta(hours=2),
'platform': 'java',
'score': Group.calculate_score(3, now),
'logger': 'java',
'times_seen': 3,
'first_release': None,
}
示例2: test_get_group_creation_attributes
# 需要导入模块: from sentry.models import Group [as 别名]
# 或者: from sentry.models.Group import calculate_score [as 别名]
def test_get_group_creation_attributes(self):
now = datetime(2017, 5, 3, 6, 6, 6, tzinfo=pytz.utc)
events = [
Event(
platform='javascript',
message='Hello from JavaScript',
datetime=now,
data={
'type': 'default',
'metadata': {},
'tags': [
['level', 'info'],
['logger', 'javascript'],
],
},
),
Event(
platform='python',
message='Hello from Python',
datetime=now - timedelta(hours=1),
data={
'type': 'default',
'metadata': {},
'tags': [
['level', 'error'],
['logger', 'python'],
],
},
),
Event(
platform='java',
message='Hello from Java',
datetime=now - timedelta(hours=2),
data={
'type': 'default',
'metadata': {},
'tags': [
['level', 'debug'],
['logger', 'java'],
],
},
),
]
assert get_group_creation_attributes(
get_caches(),
events,
) == {
'active_at': now - timedelta(hours=2),
'first_seen': now - timedelta(hours=2),
'last_seen': now,
'platform': 'java',
'message': 'Hello from JavaScript',
'level': logging.INFO,
'score': Group.calculate_score(3, now),
'logger': 'java',
'times_seen': 3,
'first_release': None,
'culprit': '',
'data': {
'type': 'default',
'last_received': to_timestamp(now),
'metadata': {},
},
}
示例3: get_group_creation_attributes
# 需要导入模块: from sentry.models import Group [as 别名]
# 或者: from sentry.models.Group import calculate_score [as 别名]
'times_seen': lambda event: 0,
}
backfill_fields = {
'platform': lambda caches, data, event: event.platform,
'logger': lambda caches, data, event: event.get_tag('logger') or DEFAULT_LOGGER_NAME,
'first_seen': lambda caches, data, event: event.datetime,
'active_at': lambda caches, data, event: event.datetime,
'first_release': lambda caches, data, event: caches['Release'](
caches['Project'](event.project_id).organization_id,
event.get_tag('sentry:release'),
) if event.get_tag('sentry:release') else data.get('first_release', None),
'times_seen': lambda caches, data, event: data['times_seen'] + 1,
'score': lambda caches, data, event: Group.calculate_score(
data['times_seen'] + 1,
data['last_seen'],
),
}
def get_group_creation_attributes(caches, events):
latest_event = events[0]
return reduce(
lambda data, event: merge_mappings([
data,
{name: f(caches, data, event) for name, f in backfill_fields.items()},
]),
events,
{name: f(latest_event) for name, f in initial_fields.items()},
)