mirror of https://github.com/MISP/misp-dashboard
Added support of previous date in getLastContributors
parent
cb53be4253
commit
d8ad176b72
|
@ -229,21 +229,24 @@ class Contributor_helper:
|
||||||
def getLastContributorsFromRedis(self):
|
def getLastContributorsFromRedis(self):
|
||||||
date = datetime.datetime.now()
|
date = datetime.datetime.now()
|
||||||
keyname = "CONTRIB_LAST"
|
keyname = "CONTRIB_LAST"
|
||||||
|
prev_days = 7
|
||||||
topNum = self.MAX_NUMBER_OF_LAST_CONTRIBUTOR # default Num
|
topNum = self.MAX_NUMBER_OF_LAST_CONTRIBUTOR # default Num
|
||||||
last_contrib_org = self.getZrange(keyname, date, topNum)
|
|
||||||
data = []
|
data = []
|
||||||
for org, sec in last_contrib_org:
|
for curDate in util.getXPrevDaysSpan(date, prev_days):
|
||||||
dic = {}
|
last_contrib_org = self.getZrange(keyname, curDate, topNum)
|
||||||
dic['rank'] = self.getOrgRankFromRedis(org, date)
|
for org, sec in last_contrib_org:
|
||||||
dic['orgRank'] = self.getOrgContributionRank(org)['final_rank']
|
dic = {}
|
||||||
dic['honorBadge'] = self.getOrgHonorBadges(org)
|
dic['rank'] = self.getOrgRankFromRedis(org, date)
|
||||||
dic['logo_path'] = self.getOrgLogoFromMISP(org)
|
dic['orgRank'] = self.getOrgContributionRank(org)['final_rank']
|
||||||
dic['org'] = org
|
dic['honorBadge'] = self.getOrgHonorBadges(org)
|
||||||
dic['pnts'] = self.getOrgPntFromRedis(org, date)
|
dic['logo_path'] = self.getOrgLogoFromMISP(org)
|
||||||
dic['epoch'] = sec
|
dic['org'] = org
|
||||||
data.append(dic)
|
dic['pnts'] = self.getOrgPntFromRedis(org, date)
|
||||||
|
dic['epoch'] = sec
|
||||||
|
data.append(dic)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def getContributorFromRedis(self, org):
|
def getContributorFromRedis(self, org):
|
||||||
date = datetime.datetime.now()
|
date = datetime.datetime.now()
|
||||||
epoch = self.serv_redis_db.zscore("CONTRIB_LAST", org)
|
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))
|
to_return.append(ds + datetime.timedelta(days=i))
|
||||||
return to_return
|
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):
|
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)
|
||||||
|
|
Loading…
Reference in New Issue