mirror of https://github.com/MISP/misp-dashboard
Added support of previous date in getLastContributors
parent
cb53be4253
commit
d8ad176b72
|
@ -229,9 +229,11 @@ class Contributor_helper:
|
|||
def getLastContributorsFromRedis(self):
|
||||
date = datetime.datetime.now()
|
||||
keyname = "CONTRIB_LAST"
|
||||
prev_days = 7
|
||||
topNum = self.MAX_NUMBER_OF_LAST_CONTRIBUTOR # default Num
|
||||
last_contrib_org = self.getZrange(keyname, date, topNum)
|
||||
data = []
|
||||
for curDate in util.getXPrevDaysSpan(date, prev_days):
|
||||
last_contrib_org = self.getZrange(keyname, curDate, topNum)
|
||||
for org, sec in last_contrib_org:
|
||||
dic = {}
|
||||
dic['rank'] = self.getOrgRankFromRedis(org, date)
|
||||
|
@ -244,6 +246,7 @@ class Contributor_helper:
|
|||
data.append(dic)
|
||||
return data
|
||||
|
||||
|
||||
def getContributorFromRedis(self, org):
|
||||
date = datetime.datetime.now()
|
||||
epoch = self.serv_redis_db.zscore("CONTRIB_LAST", org)
|
||||
|
|
10
util.py
10
util.py
|
@ -14,5 +14,15 @@ def getMonthSpan(date):
|
|||
to_return.append(ds + datetime.timedelta(days=i))
|
||||
return to_return
|
||||
|
||||
def getXPrevDaysSpan(date, days):
|
||||
de = date
|
||||
ds = de - datetime.timedelta(days=days)
|
||||
|
||||
delta = de - ds
|
||||
to_return = []
|
||||
for i in range(delta.days+1):
|
||||
to_return.append(de - datetime.timedelta(days=i))
|
||||
return to_return
|
||||
|
||||
def getDateStrFormat(date):
|
||||
return str(date.year)+str(date.month).zfill(2)+str(date.day).zfill(2)
|
||||
|
|
Loading…
Reference in New Issue