mirror of https://github.com/MISP/misp-dashboard
Put rankLvl multiplier in config + fixed bug log 0
parent
2685a08019
commit
eed0528f52
11
server.py
11
server.py
|
@ -100,10 +100,13 @@ def getZrange(keyCateg, date, topNum):
|
||||||
|
|
||||||
# max lvl is 16
|
# max lvl is 16
|
||||||
def getRankLevel(points):
|
def getRankLevel(points):
|
||||||
return float("{:.2f}".format(math.log(points, 2)))
|
if points == 0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return float("{:.2f}".format(math.log(points, cfg.getint('CONTRIB' ,'rankMultiplier'))))
|
||||||
def getRemainingPoints(points):
|
def getRemainingPoints(points):
|
||||||
prev = 0
|
prev = 0
|
||||||
for i in [2**x for x in range(1,17)]:
|
for i in [cfg.getint('CONTRIB' ,'rankMultiplier')**x for x in range(1,17)]:
|
||||||
if prev <= points < i:
|
if prev <= points < i:
|
||||||
return i-points
|
return i-points
|
||||||
prev = i
|
prev = i
|
||||||
|
@ -141,7 +144,8 @@ def geo():
|
||||||
@app.route("/contrib")
|
@app.route("/contrib")
|
||||||
def contrib():
|
def contrib():
|
||||||
return render_template('contrib.html',
|
return render_template('contrib.html',
|
||||||
currOrg=""
|
currOrg="",
|
||||||
|
rankMultiplier=cfg.getint('CONTRIB' ,'rankMultiplier')
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/_getLastContributor")
|
@app.route("/_getLastContributor")
|
||||||
|
@ -269,6 +273,7 @@ def getOrgRank():
|
||||||
except:
|
except:
|
||||||
org = ''
|
org = ''
|
||||||
points = random.randint(1,2**16)
|
points = random.randint(1,2**16)
|
||||||
|
#FIXME put 0 if org has no points
|
||||||
data = {'org': org, 'points': points, 'rank': getRankLevel(points), 'remainingPts': getRemainingPoints(points)}
|
data = {'org': org, 'points': points, 'rank': getRankLevel(points), 'remainingPts': getRemainingPoints(points)}
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ function generateRankingSheet(rank) {
|
||||||
td.style.padding = "2px";
|
td.style.padding = "2px";
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
var td = document.createElement('td');
|
var td = document.createElement('td');
|
||||||
td.innerHTML = i+" pnts";
|
td.innerHTML = Math.pow(rankMultiplier, i)+" pnts";
|
||||||
td.style.padding = "2px";
|
td.style.padding = "2px";
|
||||||
tr.style.textAlign = "center";
|
tr.style.textAlign = "center";
|
||||||
if (i == rank) { // current org rank
|
if (i == rank) { // current org rank
|
||||||
|
|
|
@ -240,6 +240,7 @@
|
||||||
|
|
||||||
/* DATA FROM CONF */
|
/* DATA FROM CONF */
|
||||||
var currOrg = "{{ currOrg }}";
|
var currOrg = "{{ currOrg }}";
|
||||||
|
var rankMultiplier = {{ rankMultiplier }};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ url_for('static', filename='js/contrib.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/contrib.js') }}"></script>
|
||||||
|
|
Loading…
Reference in New Issue