Esempio n. 1
0
def get_survey_results(surveyQuestion):
	resultsDict = defaultdict(int)

	collection = database.getCurrentCollection()
	results = collection.find({surveyQuestion:{'$exists': True}})
	for result in results:
		answer = result[surveyQuestion][0]  #TODO: Questions with multiple answers?
		resultsDict[answer] += 1

	return resultsDict
Esempio n. 2
0
def getLastSurveys(amount):
	results = list(database.getCurrentCollection().find().sort("_id", -1).limit(int(amount)))
	return make_response(json.dumps(results, default=json_util.default), 200)
Esempio n. 3
0
def getSurveyCount():
	count = database.getCurrentCollection().count()
	return make_response(str(count), 200)
Esempio n. 4
0
def completedSurvey():
	database.getCurrentCollection().insert(dict(request.form))
	return make_response("OK", 200)
Esempio n. 5
0
def getLastSurveys(amount):
    results = list(database.getCurrentCollection().find().sort("_id", -1).limit(int(amount)))
    return make_response(json.dumps(results, default=json_util.default), 200)
Esempio n. 6
0
def getSurveyCount():
    count = database.getCurrentCollection().count()
    return make_response(str(count), 200)
Esempio n. 7
0
def completedSurvey():
    database.getCurrentCollection().insert(dict(request.form))
    return make_response("OK", 200)