<s> from __future__ import absolute_import <EOL> from datetime import timedelta <EOL> from django . utils import timezone <EOL> from rest_framework . response import Response <EOL> from sentry . api . bases . team import TeamEndpoint <EOL> from sentry . api . serializers import serialize <EOL> from sentry . models import Group , GroupStatus , Project <EOL> class TeamGroupsNewEndpoint ( TeamEndpoint ) : <EOL> def get ( self , request , team ) : <EOL> """<STR_LIT>""" <EOL> minutes = int ( request . REQUEST . get ( '<STR_LIT>' , <NUM_LIT:15> ) ) <EOL> limit = min ( <NUM_LIT:100> , int ( request . REQUEST . get ( '<STR_LIT>' , <NUM_LIT:10> ) ) ) <EOL> project_list = Project . objects . get_for_user ( user = request . user , team = team ) <EOL> project_dict = dict ( ( p . id , p ) for p in project_list ) <EOL> cutoff = timedelta ( minutes = minutes ) <EOL> cutoff_dt = timezone . now ( ) - cutoff <EOL> group_list = list ( Group . objects . filter ( <EOL> project__in = project_dict . keys ( ) , <EOL> status = GroupStatus . UNRESOLVED , <EOL> active_at__gte = cutoff_dt , <EOL> ) . extra ( <EOL> select = { '<STR_LIT>' : '<STR_LIT>' } , <EOL> ) . order_by ( '<STR_LIT>' , '<STR_LIT>' ) [ : limit ] ) <EOL> for group in group_list : <EOL> group . _project_cache = project_dict . get ( group . project_id ) <EOL> return Response ( serialize ( group_list , request . user ) ) </s>
