def pull_kanban(self, project, time_range): if 'BRD-' + project.key not in self.cache.data[project.key].keys(): kanban = Release() kanban.key = 'BRD-%s' % project.key kanban.version = kanban.key kanban.name = 'Kanban Board' transaction.begin() self.cache.data[project.key][kanban.key] = kanban transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', str(project.key), kanban.key]) self.cache.catalog.index_doc(docid, kanban) transaction.commit() else: kanban = self.cache.data[project.key]['BRD-' + project.key] self.pull_kanban_stories(project, kanban, time_range)
def pull_scrum(self, project, time_range): for spr in self.agile.sprints(int(project.key)): print 'Sprint:', spr.name sid = getattr(spr, 'id') if str(sid) not in self.cache.data[project.key].keys(): sprint = Release() sprint.key = str(sid) sprint.version = str(sid) sprint.name = spr.name transaction.begin() self.cache.data[project.key][str(sid)] = sprint transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', project.key, str(sid)]) self.cache.catalog.index_doc(docid, sprint) transaction.commit() else: sprint = self.cache.data[project.key][str(sid)] self.pull_scrum_stories(project, sprint)
def make_release(self, average, std, stories, bandwidth, count, num_pairs, teams, std_dev_ct, avg_pts, std_pts): release = Release() sim = len(dao.Jira.cache.data['SIMS']) + 1 release.version = 'SIM-%d' % sim transaction.begin() dao.Jira.cache.data['SIMS'][release.version] = release transaction.commit() #tasks = scipy.stats.norm.rvs(loc=average, scale=std, size=stories) tasks = numpy.random.gumbel(loc=average, scale=std, size=stories) tasks = [round(task, 1) if task >= 0 else 0. for task in tasks] points = self.get_estimates(avg_pts, std_pts, stories) dev_capacity = self.get_pairs(bandwidth, std_dev_ct, num_pairs) command = 'simulate -s %d -a %.1f -d %.1f -p %d -b %.1f -v %.1f -c %d' \ % (stories, average, std, num_pairs, bandwidth, std_dev_ct, count) simulations[sim] = {'runs': {}} simulations[sim]['command'] = command simulations[sim]['runs'][0] = {} simulations[sim]['runs'][0]['tasks'] = copy.copy(tasks) pairs = dict((k, round(v, 1)) for (k, v) in zip(xrange(num_pairs), dev_capacity)) simulations[sim]['runs'][0]['pairs'] = copy.copy(pairs) capacity = sum(pairs.values()) count = 1 for estimate in points: story = Story('SIM-X%d' % count) story.id = count story.points = int(estimate) story.title = 'Story %d for simulation %d' % (count, sim) story.fix_versions = PersistentList() story.fix_versions.append('SIM-%d' % sim) story.history = History() ct = numpy.random.gumbel(loc=average, scale=std) + 1 months = int((ct / 30) ) + 3 # TODO: Fix this days = int(ct % 30) + 1 started = datetime.datetime(2013, 3, 1, 12, 0, 0) resolved = datetime.datetime(2013, months, days, 12, 0, 0) story.history.data.append((started, 1, 3, 'Sim PO 1')) story.history.data.append((resolved, 3, 6, 'Sim Dev 1')) story.status = 6 story.created = datetime.datetime.now() story.type = '72' story.assignee = None story.developer = None story.scrum_team = 'Sim Team %d' % int(random.random() * teams) story.project = 'SIMS' transaction.begin() release[story.key] = story transaction.commit() transaction.begin() docid = dao.Jira.cache.document_map.add( ['sim', story.project, story.fix_versions[0], story.key]) dao.Jira.cache.catalog.index_doc(docid, story) transaction.commit() count += 1 for day in xrange(20): fail = False tasked = False index = 0 for task in sorted(tasks, reverse=True): missed = 0 for pair in pairs.keys(): if pairs[pair] >= task: pairs[pair] -= task tasked = True break if not tasked: missed = task fail = True break tasked = False return release.version
def make_story(self, key, data, links=True): if not data['fields']['fixVersions']: return None transaction.begin() story = Story(key) story.id = int(data['id']) story.history = History(data['changelog']) story.url = data['self'] story.title = data['fields']['summary'] story.fix_versions = PersistentList() for version in data['fields']['fixVersions']: story.fix_versions.append(version['name']) story.fix_version = data['fields']['fixVersions'] story.created = datetime.datetime.fromtimestamp(time.mktime( time.strptime(data['fields']['created'][:23], '%Y-%m-%dT%H:%M:%S.%f'))) story.type = data['fields']['issuetype']['id'] story.assignee = data['fields']['assignee'] story.developer = data['fields']['customfield_13435'] story.rank = data['fields']['customfield_12242'] if 'customfield_10722' in data['fields'] and data['fields'][ 'customfield_10722']: story.root_cause = data['fields']['customfield_10722'][ 'value'].strip() else: story.root_cause = '' if 'customfield_13330' in data['fields'] and data['fields'][ 'customfield_13330']: story.root_cause_details = data['fields']['customfield_13330'] else: story.root_cause_details = '' story.scrum_team = None if data['fields'].has_key('customfield_11261'): if data['fields']['customfield_11261']: story.scrum_team = data['fields']['customfield_11261'][ 'value'].strip() else: story.scrum_team = None story.points = None if data['fields'].has_key('customfield_10792'): story.points = data['fields']['customfield_10792'] if story.points: story.points = int(story.points) story.status = int(data['fields']['status']['id']) story.project = data['fields']['project']['key'] if not story.project in self.cache.data: self.cache.data[story.project] = Project(story.project, data['fields']['project']['name']) project = self.cache.data[story.project] for version in story.fix_versions: if version in project.keys(): if not project[version].has_key(story.key): project[version][story.key] = story else: release = Release() release.version = version release[story.key] = story project[version] = release transaction.commit() transaction.begin() docid = self.cache.document_map.add( ['jira', story.project, story.fix_versions[0], story.key]) self.cache.catalog.index_doc(docid, story) transaction.commit() if not links: return story transaction.begin() for link in data['fields']['issuelinks']: if link.has_key('outwardIssue'): type = link['type']['name'] key = link['outwardIssue']['key'] if not type in story['links']['out'].keys(): story['links']['out'][type] = Folder() story['links']['out'][type].key = type transaction.commit() s = self.get_story(key) if not s: continue story['links']['out'][type][key] = s else: if not key in story['links']['out'][type].keys(): s = self.get_story(key) if not s: continue story['links']['out'][type][key] = s elif link.has_key('inwardIssue'): type = link['type']['name'] key = link['inwardIssue']['key'] if not type in story['links']['in'].keys(): story['links']['in'][type] = Folder() story['links']['in'][type].key = type transaction.commit() s = self.get_story(key) if not s: continue story['links']['in'][type][key] = s else: if not key in story['links']['in'][type].keys(): s = self.get_story(key) if not s: continue story['links']['in'][type][key] = s transaction.commit() return story