in ForgeUserStats/forgeuserstats/controllers/userstats.py [0:0]
def _getDataForCategory(category, stats):
totcommits = stats.getCommits(category)
tottickets = stats.getTickets(category)
artifacts_by_type = stats.getArtifactsByType(category)
totartifacts = artifacts_by_type.get(None)
if totartifacts:
del artifacts_by_type[None]
else:
totartifacts = dict(created=0, modified=0)
lmcommits = stats.getLastMonthCommits(category)
lm_artifacts_by_type = stats.getLastMonthArtifactsByType(category)
lm_totartifacts = stats.getLastMonthArtifacts(category)
lm_tickets = stats.getLastMonthTickets(category)
days = (datetime.utcnow() - stats.start_date).days
if days >= 30:
pmartifacts = dict(
created=round(totartifacts['created'] * 30.0 / days, 2),
modified=round(totartifacts['modified'] * 30.0 / days, 2))
pmcommits = dict(
number=round(totcommits['number'] * 30.0 / days, 2),
lines=round(totcommits['lines'] * 30.0 / days, 2))
pmtickets = dict(
assigned=round(tottickets['assigned'] * 30.0 / days, 2),
revoked=round(tottickets['revoked'] * 30.0 / days, 2),
solved=round(tottickets['solved'] * 30.0 / days, 2),
averagesolvingtime='n/a')
for key in artifacts_by_type:
value = artifacts_by_type[key]
artifacts_by_type[key]['pmcreated'] = \
round(value['created'] * 30.0 / days, 2)
artifacts_by_type[key]['pmmodified'] = \
round(value['modified'] * 30.0 / days, 2)
else:
pmartifacts = dict(created='n/a', modified='n/a')
pmcommits = dict(number='n/a', lines='n/a')
pmtickets = dict(
assigned='n/a',
revoked='n/a',
solved='n/a',
averagesolvingtime='n/a')
for key in artifacts_by_type:
artifacts_by_type[key]['pmcreated'] = 'n/a'
artifacts_by_type[key]['pmmodified'] = 'n/a'
return dict(
days=days,
totcommits=totcommits,
lastmonthcommits=lmcommits,
lastmonthtickets=lm_tickets,
tottickets=tottickets,
permonthcommits=pmcommits,
totartifacts=totartifacts,
lastmonthartifacts=lm_totartifacts,
permonthartifacts=pmartifacts,
artifacts_by_type=artifacts_by_type,
lastmonth_artifacts_by_type=lm_artifacts_by_type,
permonthtickets=pmtickets)