Accelerate daily stat
This commit is contained in:
parent
720bce3a85
commit
e2b75d6cc5
1 changed files with 25 additions and 6 deletions
|
@ -13,10 +13,15 @@ from common.rocketchathelper import getAllChannels, getAllMessages, Connection
|
||||||
from common.savehelper import save
|
from common.savehelper import save
|
||||||
from common.charthelper import createElement, getColor, setTsunamyInfo, getTsunamy, Tsunami
|
from common.charthelper import createElement, getColor, setTsunamyInfo, getTsunamy, Tsunami
|
||||||
|
|
||||||
|
begin = datetime.now()
|
||||||
|
end = datetime.now()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
rocket = Connection()
|
rocket = Connection()
|
||||||
nbElements = 30
|
nbElements = 30
|
||||||
|
|
||||||
|
global begin, end
|
||||||
|
|
||||||
labels = [None] * nbElements
|
labels = [None] * nbElements
|
||||||
messagesByChannel = []
|
messagesByChannel = []
|
||||||
usersByChannel = []
|
usersByChannel = []
|
||||||
|
@ -54,20 +59,20 @@ def main():
|
||||||
dataUsers = []
|
dataUsers = []
|
||||||
print( channel['name'] )
|
print( channel['name'] )
|
||||||
begin = date - timedelta(nbElements)
|
begin = date - timedelta(nbElements)
|
||||||
end = begin + timedelta(1)
|
end = begin + timedelta(nbElements)
|
||||||
|
|
||||||
tsunamy = getTsunamy(channel)
|
tsunamy = getTsunamy(channel)
|
||||||
|
|
||||||
|
messages = getAllMessages(rocket, channel['_id'], begindate= begin, enddate= end)
|
||||||
|
end = begin + timedelta(1)
|
||||||
|
|
||||||
for id in range(0, nbElements):
|
for id in range(0, nbElements):
|
||||||
if uniqueUserGlobal[id] == None:
|
if uniqueUserGlobal[id] == None:
|
||||||
uniqueUserGlobal[id] = []
|
uniqueUserGlobal[id] = []
|
||||||
labels[id] = begin.strftime("%x")
|
labels[id] = begin.strftime("%x")
|
||||||
print(f"\t{labels[id]}")
|
print(f"\t{labels[id]}")
|
||||||
begindate = begin.isoformat()
|
|
||||||
enddate = end.isoformat()
|
|
||||||
|
|
||||||
resultMess = getAllMessages(rocket, channel['_id'], begindate= begindate, enddate=enddate)
|
resultMess = list(filter(filter_message, messages))
|
||||||
resultMess = list(filter(lambda mess: 't' not in mess, resultMess))
|
|
||||||
length = len(resultMess)
|
length = len(resultMess)
|
||||||
dataMess.append(length)
|
dataMess.append(length)
|
||||||
|
|
||||||
|
@ -101,5 +106,19 @@ def main():
|
||||||
|
|
||||||
save(info, "chat_stat_daily")
|
save(info, "chat_stat_daily")
|
||||||
|
|
||||||
|
def filter_message(mess):
|
||||||
|
if 't' in mess:
|
||||||
|
return False
|
||||||
|
|
||||||
|
date = datetime.strptime(mess["ts"], "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||||
|
|
||||||
|
if date < begin:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if end < date:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
Loading…
Reference in a new issue