mirror of https://github.com/MISP/misp-dashboard
Updated org contrib. overtime to display the date
parent
e554158467
commit
6b85144164
|
@ -292,21 +292,21 @@ class Contributor_helper:
|
||||||
# show current top 5 org points overtime (last 5 days)
|
# show current top 5 org points overtime (last 5 days)
|
||||||
for dic in topSortedOrg[0:5]:
|
for dic in topSortedOrg[0:5]:
|
||||||
org = dic['org']
|
org = dic['org']
|
||||||
overtime = []
|
|
||||||
to_append = self.getOrgOvertime(org)
|
to_append = self.getOrgOvertime(org)
|
||||||
data.append(to_append)
|
data.append(to_append)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def getOrgOvertime(self, org):
|
def getOrgOvertime(self, org):
|
||||||
overtime = []
|
overtime = []
|
||||||
today = datetime.datetime.now()
|
today = datetime.datetime.today()
|
||||||
for deltaD in range(1,6,1):
|
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
date = (datetime.datetime(today.year, today.month, today.day) - datetime.timedelta(days=deltaD))
|
for curDate in util.getXPrevDaysSpan(today, 7):
|
||||||
keyname = 'CONTRIB_DAY:'+util.getDateStrFormat(date)
|
timestamp = util.getTimestamp(curDate)
|
||||||
|
keyname = 'CONTRIB_DAY:'+util.getDateStrFormat(curDate)
|
||||||
org_score = self.serv_redis_db.zscore(keyname, org)
|
org_score = self.serv_redis_db.zscore(keyname, org)
|
||||||
if org_score is None:
|
if org_score is None:
|
||||||
org_score = 0
|
org_score = 0
|
||||||
overtime.append([deltaD, org_score])
|
overtime.append([timestamp, org_score])
|
||||||
to_return = {'label': org, 'data': overtime}
|
to_return = {'label': org, 'data': overtime}
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ function updateProgressHeader(org) {
|
||||||
// transform secs into date
|
// transform secs into date
|
||||||
var new_data = [];
|
var new_data = [];
|
||||||
for(list of data['data']) {
|
for(list of data['data']) {
|
||||||
new_data.push([new Date(list[0]*1000), list[1]]);
|
new_data.push([list[0]*1000, list[1]]);
|
||||||
}
|
}
|
||||||
data['data'] = new_data;
|
data['data'] = new_data;
|
||||||
toPlot.push(data);
|
toPlot.push(data);
|
||||||
|
@ -554,7 +554,7 @@ $(document).ready(function() {
|
||||||
for(i in data){
|
for(i in data){
|
||||||
var new_data = [];
|
var new_data = [];
|
||||||
for(list of data[i]['data']) {
|
for(list of data[i]['data']) {
|
||||||
new_data.push([new Date(list[0]*1000), list[1]]);
|
new_data.push([list[0]*1000, list[1]]);
|
||||||
}
|
}
|
||||||
data[i]['data'] = new_data;
|
data[i]['data'] = new_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="panel panel-default" style="height: 100%;">
|
<div class="panel panel-default" style="height: 100%;">
|
||||||
<div class="panel-heading bg-info" style="font-weight: bold;">
|
<div class="panel-heading bg-info" style="font-weight: bold;">
|
||||||
<i class="fa fa-th-list " style="margin-right: 5px; color: #f0ad4e;"></i><b>Contributors and Categories (total)</b>
|
<i class="fa fa-th-list " style="margin-right: 5px; color: #f0ad4e;"></i><b>Contributors and categories (total)</b>
|
||||||
</div>
|
</div>
|
||||||
<div id="panelRanking" class="panel-body" style="height: 100%;">
|
<div id="panelRanking" class="panel-body" style="height: 100%;">
|
||||||
|
|
||||||
|
|
5
util.py
5
util.py
|
@ -1,4 +1,4 @@
|
||||||
import datetime
|
import datetime, time
|
||||||
|
|
||||||
ONE_DAY = 60*60*24
|
ONE_DAY = 60*60*24
|
||||||
|
|
||||||
|
@ -26,3 +26,6 @@ def getXPrevDaysSpan(date, days):
|
||||||
|
|
||||||
def getDateStrFormat(date):
|
def getDateStrFormat(date):
|
||||||
return str(date.year)+str(date.month).zfill(2)+str(date.day).zfill(2)
|
return str(date.year)+str(date.month).zfill(2)+str(date.day).zfill(2)
|
||||||
|
|
||||||
|
def getTimestamp(date):
|
||||||
|
return time.mktime(date.timetuple())
|
||||||
|
|
Loading…
Reference in New Issue