Changed the /chals/colves endpoint and associated javascript to
index solves by challenge id rather than by challenge name

Closes (#169)
selenium-screenshot-testing
Victor "Nate" Graf 2016-12-07 23:26:03 -06:00 committed by Kevin Chung
parent 4f4d6cae22
commit 22f57751e0
2 changed files with 5 additions and 5 deletions

View File

@ -74,7 +74,7 @@ def chals_per_solves():
.join(Challenges, solves_sub.columns.chalid == Challenges.id).all()
json = {}
for chal, count, name in solves:
json[name] = count
json[chal] = count
db.session.close()
return jsonify(json)

View File

@ -136,13 +136,13 @@ function marksolves(cb) {
function updatesolves(cb){
$.get(script_root + '/chals/solves', function (data) {
var solves = $.parseJSON(JSON.stringify(data));
var chals = Object.keys(solves);
var chalids = Object.keys(solves);
for (var i = 0; i < chals.length; i++) {
for (var i = 0; i < chalids.length; i++) {
var obj = $.grep(challenges['game'], function (e) {
return e.name == chals[i];
return e.id == chalids[i];
})[0];
obj.solves = solves[chals[i]]
obj.solves = solves[chalids[i]]
};
if (cb) {
cb();