本文整理汇总了Python中sentry.constants.SORT_CLAUSES类的典型用法代码示例。如果您正苦于以下问题:Python SORT_CLAUSES类的具体用法?Python SORT_CLAUSES怎么用?Python SORT_CLAUSES使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SORT_CLAUSES类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: has_trending
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_'):
event_list = Group.objects.get_accelerated(event_list, minutes=int(sort.split('_', 1)[1]))
date_from = request.GET.get('df')
time_from = request.GET.get('tf')
date_to = request.GET.get('dt')
time_to = request.GET.get('tt')
today = datetime.datetime.utcnow()
开发者ID:adamsc64,项目名称:sentry,代码行数:30,代码来源:groups.py
示例2: get
def get(self, request, project_id):
project = Project.objects.get(
id=project_id,
)
assert_perm(project, request.user, request.auth)
group_list = Group.objects.all()
if request.user.is_authenticated() and request.GET.get('bookmarks'):
group_list = group_list.filter(
bookmark_set__project=project,
bookmark_set__user=request.user,
)
else:
group_list = group_list.filter(project=project)
status = request.GET.get('status')
if status:
group_list = group_list.filter(status=int(status))
tag_keys = TagKey.objects.all_keys(project)
for tag in tag_keys:
value = request.GET.get(tag)
if value:
group_list = group_list.filter(
grouptag__project=project,
grouptag__key=tag,
grouptag__value=value,
)
# TODO: dates should include timestamps
date_from = request.GET.get('since')
time_from = request.GET.get('until')
date_filter = request.GET.get('date_filter')
date_to = request.GET.get('dt')
time_to = request.GET.get('tt')
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 - timedelta(days=5)
date_to = None
if date_filter == 'first_seen':
if date_from:
group_list = group_list.filter(first_seen__gte=date_from)
elif date_to:
group_list = group_list.filter(first_seen__lte=date_to)
else:
# TODO(dcramer): a date_to no longer makes a lot of sense, and will
# need corrected when search lands
if date_from:
group_list = group_list.filter(last_seen__gte=date_from)
if date_to:
group_list = group_list.filter(last_seen__lte=date_to)
sort = request.GET.get('sort') or request.session.get('streamsort')
if sort is None:
sort = DEFAULT_SORT_OPTION
elif sort not in SORT_OPTIONS or sort.startswith('accel_'):
return HttpResponse(status=400)
# Save last sort in session
if sort != request.session.get('streamsort'):
request.session['streamsort'] = sort
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)
assert score_clause
if sort == 'tottime':
group_list = group_list.filter(time_spent_count__gt=0)
elif sort == 'avgtime':
group_list = group_list.filter(time_spent_count__gt=0)
group_list = group_list.extra(
select={'sort_value': score_clause},
)
return self.paginate(
#.........这里部分代码省略.........
开发者ID:alex-tools,项目名称:sentry,代码行数:101,代码来源:project_group_index.py
示例3: _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(
first_seen__gte=date_from,
last_seen__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
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)
if score_clause:
event_list = event_list.extra(
select={'sort_value': score_clause},
)
# HACK: don't sort by the same column twice
if sort == 'date':
event_list = event_list.order_by('-last_seen')
else:
event_list = event_list.order_by('-sort_value', '-last_seen')
cursor = request.GET.get('cursor', request.GET.get('c'))
#.........这里部分代码省略.........
开发者ID:alex-tools,项目名称:sentry,代码行数:101,代码来源:groups.py
示例4: _get_group_list
def _get_group_list(request, project, view=None):
filters = []
for cls in Filter.objects.filter(Group):
filters.append(cls(request))
event_list = Group.objects
if 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)
if view:
event_list = event_list.filter(views=view)
for filter_ in filters:
if not filter_.is_set():
continue
event_list = filter_.get_query_set(event_list)
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
if not sort.startswith('accel_'):
since = request.GET.get('since', '')
if since not in DATE_OPTIONS:
since = settings.DEFAULT_DATE_OPTION
else:
since = None
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_'):
event_list = Group.objects.get_accelerated(event_list, minutes=int(sort.split('_', 1)[1]))
if since in DATE_VALUES:
event_list = event_list.filter(last_seen__gte=datetime.datetime.now() - DATE_VALUES[since])
if sort_clause:
event_list = event_list.extra(
select={'sort_value': sort_clause},
).order_by('-sort_value', '-last_seen')
cursor = request.GET.get('cursor')
if cursor:
event_list = event_list.extra(
where=['%s > %%s' % sort_clause],
params=[cursor],
)
return filters, event_list
开发者ID:jmacul2,项目名称:sentry,代码行数:66,代码来源:groups.py
注:本文中的sentry.constants.SORT_CLAUSES类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论