def view_slice(slug): slice_ = slices.get(slug) filters = [] for filter_ in get_filters(slug): filters.append(filter_(request)) try: page = int(request.args.get('p', 1)) except (TypeError, ValueError): page = 1 query = request.args.get('content') is_search = query # TODO: this needs to pull in the event list for this slice event_list = Group.objects.all() sort = request.args.get('sort') if sort == 'date': event_list = event_list.order_by('-last_seen') elif sort == 'new': event_list = event_list.order_by('-first_seen') elif sort == 'count': event_list = event_list.order_by('-count') else: sort = 'priority' event_list = event_list.order_by('-score') filters = [] any_filter = False # for filter_ in filters: # if not filter_.is_set(): # continue # any_filter = True # event_list = filter_.get_query_set(event_list) today = datetime.datetime.now() has_realtime = page == 1 return render_template('sentry/slice.html', **{ 'slice_name': slice_['name'], 'has_realtime': has_realtime, 'event_list': event_list, 'today': today, 'query': query, 'sort': sort, 'any_filter': any_filter, 'request': request, 'filters': filters, })
def get_filters(slug): global _FILTER_CACHE if slug not in _FILTER_CACHE: slice_ = slices.get(slug) filters = [] for filter_ in slice_.get('FILTERS', []): if filter_.endswith('sentry.filters.SearchFilter'): continue module_name, class_name = filter_.rsplit('.', 1) try: module = __import__(module_name, {}, {}, class_name) filter_ = getattr(module, class_name) except Exception: logger = logging.getLogger('sentry.errors') logger.exception('Unable to import %s' % (filter_,)) continue filters.append(filter_) _FILTER_CACHE[slug] = filters for f in _FILTER_CACHE[slug]: yield f