This commit is contained in:
Mickael 2019-09-01 12:50:21 +02:00
parent 11ca40c677
commit 9132f4f03f
4 changed files with 10 additions and 16 deletions

View file

@ -1,3 +1,8 @@
from rocketchat_API.rocketchat import RocketChat
def Connection():
return RocketChat(None, None, auth_token= os.environ['ROCKETCHAT_AUTH'], user_id= os.environ['ROCKETCHAT_USERID'], server_url=os.environ['ROCKETCHAT_SERVER'])
def getNodesOrigin(channel): def getNodesOrigin(channel):
nodes = [] nodes = []
if 'description' not in channel: if 'description' not in channel:

View file

@ -3,6 +3,7 @@ import os
import json import json
from datetime import datetime from datetime import datetime
from monthdelta import monthdelta from monthdelta import monthdelta
from common.rocketchathelper import getAllChannels, Connection
def main(): def main():
print("Start chat info generation") print("Start chat info generation")
@ -18,7 +19,7 @@ def main():
recent_date = datetime.now() - monthdelta() recent_date = datetime.now() - monthdelta()
rocket = RocketChat(None, None, auth_token= os.environ['ROCKETCHAT_AUTH'], user_id= os.environ['ROCKETCHAT_USERID'], server_url=os.environ['ROCKETCHAT_SERVER']) rocket = Connection()
print("Check users") print("Check users")
users = getAllActiveUsers(rocket) users = getAllActiveUsers(rocket)
@ -92,18 +93,6 @@ def save(info):
with open(statsFilePath, "w") as file_write: with open(statsFilePath, "w") as file_write:
json.dump(info, file_write) json.dump(info, file_write)
def getAllChannels(rocket):
index = 0
allChannels = []
while True:
channels = rocket.channels_list(offset = index).json()
allChannels.extend([ channel for channel in channels['channels'] if 'archived' not in channel])
if channels['count'] + channels['offset'] >= channels['total']:
break
index += channels['count']
return allChannels
def getAllActiveUsers(rocket): def getAllActiveUsers(rocket):
index = 0 index = 0
allUsers = [] allUsers = []

View file

@ -10,7 +10,7 @@ import os
import random import random
from datetime import datetime from datetime import datetime
from monthdelta import monthdelta from monthdelta import monthdelta
from common.channelhelper import getTsunamy, Tsunami, getAllChannels from common.rocketchathelper import getTsunamy, Tsunami, getAllChannels, Connection
def getColor(): def getColor():
r = random.randrange(255) r = random.randrange(255)
@ -49,7 +49,7 @@ def setTsunamyInfo(tsunamy, messagesDataTsunamy, id, length):
messagesDataTsunamy[Tsunami.TECHNOLOGY][id] += length messagesDataTsunamy[Tsunami.TECHNOLOGY][id] += length
def main(): def main():
rocket = RocketChat(None, None, auth_token= os.environ['ROCKETCHAT_AUTH'], user_id= os.environ['ROCKETCHAT_USERID'], server_url=os.environ['ROCKETCHAT_SERVER']) rocket = Connection()
labels = [None] * 12 labels = [None] * 12
messagesByChannel = [] messagesByChannel = []

View file

@ -1 +1 @@
{"crapauds": {"total": 2373, "recent": 180}, "canaux": {"total": 177, "recent": 98, "liste": ["semourais", "accueil", "general", "techos", "right-to-repair", "wiki-crapaud-fou", "reflexion-sur-l-argent", "cohorte-loire", "empowerment", "le-led"]}, "messages": {"total": 187094, "recent": 13313}, "cohortes": ["2607", "34", "barcelone", "belgique", "bourgogne", "bretagne", "centre", "grand-est", "grece", "grenoble", "hdf", "ile-de-france", "la-reunion", "loire", "lyon-st-etienne", "normandie", "paca", "paysdesavoie", "sud-ouest", "suisse"]} {"crapauds": {"total": 2180, "recent": 98}, "canaux": {"total": 184, "recent": 107, "liste": ["semourais", "techos", "right-to-repair", "libre", "cratube", "reflexion-sur-lamour", "reflexion-sur-l-argent", "animation-crapauds", "lucarn", "empowerment"]}, "messages": {"total": 192117, "recent": 12337}, "cohortes": ["2607", "34", "barcelone", "belgique", "bourgogne", "bretagne", "centre", "grand-est", "grece", "grenoble", "hdf", "ile-de-france", "la-reunion", "loire", "lyon-st-etienne", "normandie", "paca", "paysdesavoie", "sud-ouest", "suisse"]}