예제 #1
0
def get_stories(projectIds):
    session = connect()

#    for project in session.getProjects():
#        print('name=' + project.Name)
#        print(project)

    stories = {}
#    projNames = ['Red Hat Connect Tech Partner Hub']
#    projectIds = ['c97fae21-9861-496d-8643-74adc92a00bc']

    oneYear = timedelta(days=365)
    oneYearAgo = timezone.now() - oneYear

    for projectid in projectIds:
        print('projectid=%s' % (projectid,))
        queriedStories = session.get('Story', query='Project.ObjectID = "' + projectid + '"', fetch='FormattedID,Name,CreationDate,Iteration')
        queriedDefects = session.get('Defect', query='Project.ObjectID = "' + projectid + '"', fetch=True)
        queriedStories = list(queriedStories)
        queriedDefects = list(queriedDefects)
        for result in queriedStories + queriedDefects:
            createdate = datetime.strptime(result.CreationDate[0:19], "%Y-%m-%dT%H:%M:%S" )
            if createdate < oneYearAgo:
                #
                # Don't load ones over a year old. If you are still working a story after a year you have bigger problems.
                #
                continue
            story = Story()
            story.rally_id = result.FormattedID
            story.name = result.Name
            story.date_added = createdate
            if result.Iteration:
                story.sprint = result.Iteration.Name
            stories[story.rally_id] = story

    print('finished get_stories(). count is %d' % (len(stories),))
    return stories
예제 #2
0
def get_stories(projectIds):
    stories = {}
    start = 1
    pagesize = 200
    for projId in projectIds:
        lastPage = False
        page = start
        while not (lastPage):
            storyurl = agileurl + apiurl + 'projects/' + projId + '/stories?' + get_page_query_params(
                page, pagesize)
            logger.debug('Retrieving Stories from URL: ' + storyurl)
            rest_header['X-Zen-ApiKey'] = ConfigCache.get_config_value(
                'agilezen.apikey')
            response = requests.get(storyurl, headers=rest_header)
            processed_response = response.json()
            story_list = processed_response[u'items']
            count = len(story_list)  #processed_response[u'totalItems']

            for result in story_list:
                #print result
                phase = result[u'phase']
                ignorestates = [
                    u'Backlog', u'Ready', u'Archive',
                    u'Release Candidate / Production'
                ]
                if not phase[u'name'] in ignorestates:
                    story = Story()
                    story.rally_id = result[u'id']
                    story.name = result[u'text'][0:100]
                    story.sprint = result[u'text'][0:3]
                    story.url = agileurl + 'project/' + projId + '/story/%d' % result[
                        u'id']
                    try:
                        story.sprint = '%s - %s' % (projId,
                                                    result[u'deadline'])
                        #story.release_date = result[u'deadline']
                    except:
                        story.sprint = '%s' % projId
                        logger.debug('no deadline for story %d' %
                                     story.rally_id)
                    stories[story.rally_id] = story

            if count == 0:
                lastPage = True
            page += 1

    return stories
def get_stories(projectIds):
    stories = {}
    start = 1
    pagesize = 200
    for projId in projectIds:
        lastPage = False
        page = start
        while not(lastPage):
            storyurl = agileurl+apiurl+'projects/'+ projId +'/stories?'+ get_page_query_params(page, pagesize)
            logger.debug('Retrieving Stories from URL: '+storyurl)
            rest_header['X-Zen-ApiKey'] = ConfigCache.get_config_value('agilezen.apikey')
            response = requests.get(storyurl, headers=rest_header)
            processed_response = response.json()
            story_list = processed_response[u'items']
            count = len(story_list) #processed_response[u'totalItems']

            for result in story_list:
                #print result
                phase = result[u'phase']
                ignorestates = [u'Backlog', u'Ready', u'Archive',  u'Release Candidate / Production']
                if not phase[u'name'] in ignorestates:
                    story = Story()
                    story.rally_id = result[u'id']
                    story.name = result[u'text'][0:100]
                    story.sprint = result[u'text'][0:3]
                    story.url = agileurl+'project/'+ projId +'/story/%d'%result[u'id']
                    try:
                        story.sprint = '%s - %s' % (projId, result[u'deadline'])
                        #story.release_date = result[u'deadline']
                    except:
                        story.sprint = '%s'%projId
                        logger.debug('no deadline for story %d'%story.rally_id)
                    stories[story.rally_id] = story
                    
            if count == 0:
                lastPage = True
            page += 1
            
    return stories
예제 #4
0
def get_stories(projectIds):
    session = connect()

#    for project in session.getProjects():
#        print('name=' + project.Name)
#        print(project)

    stories = {}
#    projNames = ['Red Hat Connect Tech Partner Hub']
#    projectIds = ['c97fae21-9861-496d-8643-74adc92a00bc']

    oneYear = timedelta(days=365)
    oneYearAgo = timezone.now() - oneYear

    for projectid in projectIds:
        print('projectid=%s' % (projectid,))
        queriedStories = session.get('Story', query='Project.ObjectID = "' + projectid + '"', fetch='FormattedID,Name,CreationDate,Iteration', _disableAugments=True)
        queriedDefects = session.get('Defect', query='Project.ObjectID = "' + projectid + '"', fetch=True, _disableAugments=True)
        queriedStories = list(queriedStories)
        queriedDefects = list(queriedDefects)
        for result in queriedStories + queriedDefects:
            createdate = datetime.strptime(result.CreationDate[0:19], "%Y-%m-%dT%H:%M:%S" )
            if createdate < oneYearAgo:
                #
                # Don't load ones over a year old. If you are still working a story after a year you have bigger problems.
                #
                continue
            story = Story()
            story.rally_id = result.FormattedID
            story.name = result.Name
            story.date_added = createdate
            if result.Iteration:
                story.sprint = result.Iteration.Name
            stories[story.rally_id] = story

    print('finished get_stories(). count is %d' % (len(stories),))
    return stories
예제 #5
0
def addtostory(request):

    log = logging.getLogger('user')

    results = {'success':False}

    if request.method == u'GET':
        story = None
        try:
            storyId = request.GET['storyId']
            if (storyId == 'null'):
                storyId = ''
            storyName = request.GET['storyName']
            storyRallyId = request.GET['storyRallyId']
            storyURL = request.GET['storyURL']

            if len(storyId) > 0 or len(storyRallyId) > 0:

                if len(storyId) > 0:
                    try:
                        story = Story.objects.get(id=storyId)
                    except ObjectDoesNotExist:
                        pass

                if not story and len(storyRallyId) > 0:
                    try:
                        story = Story.objects.get(rally_id=storyRallyId)
                    except ObjectDoesNotExist:
                        pass

                if not story:
                    story = Story()
                    if len(storyRallyId) > 0:
                        story.rally_id = storyRallyId
                        story.url = "https://rally1.rallydev.com/slm/detail/" + story.rally_id
                    if len(storyURL) > 0:
                        story.url = storyURL

                if len(storyName) > 0:
                    story.name = storyName
                    
                story.save()
                
            objectIds = request.GET.getlist('itemid');

            objects = DeployableObject.objects.filter(id__in=objectIds)
            for object in objects:
                if story:
                    object.pending_stories.add(story)
                    object.release_status = 'p'
                object.save()

            transIds = request.GET.getlist('transid');

            translations = DeployableTranslation.objects.filter(id__in=transIds)
            for translation in translations:
                if story:
                    translation.pending_stories.add(story)
                    translation.release_status = 'p'
                translation.save()

            results = {'success':True}
        except Exception as ex:
            tb = traceback.format_exc()
            results = {'success':False, 'error':'ERROR: ' + tb}

    js = json.dumps(results)
    return HttpResponse(js, content_type='application/json')
예제 #6
0
def addtostory(request):

    log = logging.getLogger('user')

    results = {'success': False}

    if request.method == u'GET':
        story = None
        try:
            storyId = request.GET['storyId']
            if (storyId == 'null'):
                storyId = ''
            storyName = request.GET['storyName']
            storyRallyId = request.GET['storyRallyId']
            storyURL = request.GET['storyURL']

            if len(storyId) > 0 or len(storyRallyId) > 0:

                if len(storyId) > 0:
                    try:
                        story = Story.objects.get(id=storyId)
                    except ObjectDoesNotExist:
                        pass

                if not story and len(storyRallyId) > 0:
                    try:
                        story = Story.objects.get(rally_id=storyRallyId)
                    except ObjectDoesNotExist:
                        pass

                if not story:
                    story = Story()
                    if len(storyRallyId) > 0:
                        story.rally_id = storyRallyId
                        story.url = "https://rally1.rallydev.com/slm/detail/" + story.rally_id
                    if len(storyURL) > 0:
                        story.url = storyURL

                if len(storyName) > 0:
                    story.name = storyName

                story.save()

            objectIds = request.GET.getlist('itemid')

            objects = DeployableObject.objects.filter(id__in=objectIds)
            for object in objects:
                if story:
                    object.pending_stories.add(story)
                    object.release_status = 'p'
                object.save()

            transIds = request.GET.getlist('transid')

            translations = DeployableTranslation.objects.filter(
                id__in=transIds)
            for translation in translations:
                if story:
                    translation.pending_stories.add(story)
                    translation.release_status = 'p'
                translation.save()

            results = {'success': True}
        except Exception as ex:
            tb = traceback.format_exc()
            results = {'success': False, 'error': 'ERROR: ' + tb}

    js = json.dumps(results)
    return HttpResponse(js, content_type='application/json')