refacto
This commit is contained in:
parent
11ca40c677
commit
9132f4f03f
4 changed files with 10 additions and 16 deletions
|
@ -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):
|
||||
nodes = []
|
||||
if 'description' not in channel:
|
|
@ -3,6 +3,7 @@ import os
|
|||
import json
|
||||
from datetime import datetime
|
||||
from monthdelta import monthdelta
|
||||
from common.rocketchathelper import getAllChannels, Connection
|
||||
|
||||
def main():
|
||||
print("Start chat info generation")
|
||||
|
@ -18,7 +19,7 @@ def main():
|
|||
|
||||
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")
|
||||
users = getAllActiveUsers(rocket)
|
||||
|
@ -92,18 +93,6 @@ def save(info):
|
|||
with open(statsFilePath, "w") as 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):
|
||||
index = 0
|
||||
allUsers = []
|
||||
|
|
|
@ -10,7 +10,7 @@ import os
|
|||
import random
|
||||
from datetime import datetime
|
||||
from monthdelta import monthdelta
|
||||
from common.channelhelper import getTsunamy, Tsunami, getAllChannels
|
||||
from common.rocketchathelper import getTsunamy, Tsunami, getAllChannels, Connection
|
||||
|
||||
def getColor():
|
||||
r = random.randrange(255)
|
||||
|
@ -49,7 +49,7 @@ def setTsunamyInfo(tsunamy, messagesDataTsunamy, id, length):
|
|||
messagesDataTsunamy[Tsunami.TECHNOLOGY][id] += length
|
||||
|
||||
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
|
||||
messagesByChannel = []
|
||||
|
|
|
@ -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"]}
|
Loading…
Reference in a new issue