mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-19 06:54:20 +01:00
Closes #169
Changed the /chals/colves endpoint and associated javascript to index solves by challenge id rather than by challenge name Closes (#169)
This commit is contained in:
committed by
Kevin Chung
parent
4f4d6cae22
commit
22f57751e0
@@ -74,7 +74,7 @@ def chals_per_solves():
|
|||||||
.join(Challenges, solves_sub.columns.chalid == Challenges.id).all()
|
.join(Challenges, solves_sub.columns.chalid == Challenges.id).all()
|
||||||
json = {}
|
json = {}
|
||||||
for chal, count, name in solves:
|
for chal, count, name in solves:
|
||||||
json[name] = count
|
json[chal] = count
|
||||||
db.session.close()
|
db.session.close()
|
||||||
return jsonify(json)
|
return jsonify(json)
|
||||||
|
|
||||||
|
|||||||
@@ -136,13 +136,13 @@ function marksolves(cb) {
|
|||||||
function updatesolves(cb){
|
function updatesolves(cb){
|
||||||
$.get(script_root + '/chals/solves', function (data) {
|
$.get(script_root + '/chals/solves', function (data) {
|
||||||
var solves = $.parseJSON(JSON.stringify(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) {
|
var obj = $.grep(challenges['game'], function (e) {
|
||||||
return e.name == chals[i];
|
return e.id == chalids[i];
|
||||||
})[0];
|
})[0];
|
||||||
obj.solves = solves[chals[i]]
|
obj.solves = solves[chalids[i]]
|
||||||
};
|
};
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb();
|
cb();
|
||||||
|
|||||||
Reference in New Issue
Block a user