Skip to content

Commit

Permalink
Updated to reflect changes in models.py, refer last commit. Using sim…
Browse files Browse the repository at this point in the history
…plejson instead of jsonify.
  • Loading branch information
nxvipin committed Mar 30, 2012
1 parent 1558468 commit 8f4010a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions application/api.py
Expand Up @@ -3,8 +3,8 @@
API Version is ignored in the prototype.
"""

from flask import render_template, flash, url_for, redirect, json
from flask import jsonify
from flask import render_template, flash, url_for, redirect
import simplejson
import models
from teamlist import teams

Expand All @@ -16,16 +16,17 @@ def team(api_version, team):
Only supports the 'teammetrics' project now.
"""
if team == "teammetrics":
return jsonify( results={ "authorstats" : models.extractMetrics(teams[team]["authorstats"],"authorstat"),
"commitstats" : models.extractMetrics(teams[team]["commitstats"],"commitstat"),
"commitlines" : models.extractMetrics(teams[team]["commitlines"],"commitlines")
})
return simplejson.dumps( [ models.extractMetrics(teams[team]["authorstats"],"authorstat"),
models.extractMetrics(teams[team]["commitstats"],"commitstat"),
models.extractMetrics(teams[team]["commitlines"],"commitlines")]
)
else:
return jsonify(results="No data available. Try 'teammetrics' as team name.")

def teamMetrics(api_version, team, metric):
"""
Given a team and a particular metric, the available data is returned in JSON format.
"""
return jsonify(results=models.extractMetrics(team,metric))
r = models.extractMetrics(team,metric)
return simplejson.dumps([r,r])

0 comments on commit 8f4010a

Please sign in to comment.