<s> from __future__ import absolute_import <EOL> from rest_framework . response import Response <EOL> from sentry . api . serializers import serialize , StreamGroupSerializer <EOL> from sentry . api . paginator import OffsetPaginator <EOL> from sentry . models import ( <EOL> Group , GroupStatus , OrganizationMemberTeam , Project , ProjectStatus <EOL> ) <EOL> from . organizationmember import OrganizationMemberEndpoint <EOL> ERR_INVALID_STATS_PERIOD = "<STR_LIT>" <EOL> class OrganizationIssuesEndpoint ( OrganizationMemberEndpoint ) : <EOL> def get_queryset ( self , request , organization , member , project_list ) : <EOL> return Group . objects . none ( ) <EOL> def get ( self , request , organization , member ) : <EOL> """<STR_LIT>""" <EOL> stats_period = request . GET . get ( '<STR_LIT>' ) <EOL> if stats_period not in ( None , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> return Response ( { "<STR_LIT>" : ERR_INVALID_STATS_PERIOD } , status = <NUM_LIT> ) <EOL> elif stats_period is None : <EOL> stats_period = '<STR_LIT>' <EOL> elif stats_period == '<STR_LIT>' : <EOL> stats_period = None <EOL> project_list = Project . objects . filter ( <EOL> organization = organization , <EOL> team__in = OrganizationMemberTeam . objects . filter ( <EOL> organizationmember = member , <EOL> ) . values ( '<STR_LIT>' ) <EOL> ) <EOL> queryset = self . get_queryset ( request , organization , member , project_list ) <EOL> status = request . GET . get ( '<STR_LIT:status>' , '<STR_LIT>' ) <EOL> if status == '<STR_LIT>' : <EOL> queryset = queryset . filter ( <EOL> status = GroupStatus . UNRESOLVED , <EOL> ) <EOL> elif status : <EOL> return Response ( { '<STR_LIT:status>' : '<STR_LIT>' } , status = <NUM_LIT> ) <EOL> queryset = queryset . filter ( <EOL> project__status = ProjectStatus . VISIBLE , <EOL> ) <EOL> return self . paginate ( <EOL> request = request , <EOL> queryset = queryset , <EOL> order_by = '<STR_LIT>' , <EOL> paginator_cls = OffsetPaginator , <EOL> on_results = lambda x : self . _on_results ( request , x , stats_period ) , <EOL> ) <EOL> def _on_results ( self , request , results , stats_period ) : <EOL> results = serialize ( results , request . user , StreamGroupSerializer ( <EOL> stats_period = stats_period , <EOL> ) ) <EOL> if request . GET . get ( '<STR_LIT:status>' ) == '<STR_LIT>' : <EOL> results = [ <EOL> r for r in results <EOL> if r [ '<STR_LIT:status>' ] == '<STR_LIT>' <EOL> ] <EOL> return results </s>
