Generate Monthly is faster
This commit is contained in:
parent
80bf0769ac
commit
b4b664cb45
1 changed files with 10 additions and 5 deletions
|
@ -14,7 +14,13 @@ from common.rocketchathelper import getAllChannels, getAllMessages, Connection
|
|||
from common.savehelper import save
|
||||
from common.charthelper import createElement, getColor, setTsunamyInfo, Tsunami, getTsunamy
|
||||
|
||||
begin = datetime.now()
|
||||
end = datetime.now()
|
||||
|
||||
def main():
|
||||
|
||||
global begin, end
|
||||
|
||||
rocket = Connection()
|
||||
|
||||
labels = [None] * 12
|
||||
|
@ -56,6 +62,8 @@ def main():
|
|||
begin = date - monthdelta(12)
|
||||
end = begin + monthdelta(1)
|
||||
|
||||
messages = getAllMessages(rocket, channel['_id'], begindate= begin, enddate=date, count= channel['msgs'])
|
||||
|
||||
tsunamy = getTsunamy(channel)
|
||||
|
||||
for id in range(0, 12):
|
||||
|
@ -63,11 +71,8 @@ def main():
|
|||
uniqueUserGlobal[id] = []
|
||||
labels[id] = begin.strftime("%b %Y")
|
||||
print(f"\t{labels[id]}")
|
||||
begindate = begin.isoformat()
|
||||
enddate = end.isoformat()
|
||||
|
||||
resultMess = getAllMessages(rocket, channel['_id'], begindate= begindate, enddate=enddate)
|
||||
resultMess = list(filter(lambda mess: 't' not in mess, resultMess))
|
||||
|
||||
resultMess = list(filter(lambda mess: begin < datetime.strptime(mess["ts"], "%Y-%m-%dT%H:%M:%S.%fZ") < end, messages))
|
||||
length = len(resultMess)
|
||||
dataMess.append(length)
|
||||
|
||||
|
|
Loading…
Reference in a new issue