Get active user
This commit is contained in:
parent
6ce4189e61
commit
8e3beac4f6
3 changed files with 18 additions and 7 deletions
|
@ -27,21 +27,31 @@ def main():
|
|||
print("Check channels")
|
||||
channels = getAllChannels(rocket)
|
||||
channels_total = len(channels)
|
||||
|
||||
|
||||
users = []
|
||||
for channel in channels:
|
||||
messages_total += int(channel["msgs"])
|
||||
date = channel["lm"]
|
||||
channel_date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
if channel_date > recent_date:
|
||||
channels_recent += 1
|
||||
channels_list.append(channel["name"])
|
||||
|
||||
print("Check messages for channels {}".format(channel['name']))
|
||||
messages = rocket.channels_history(channel["_id"], oldest= recent_date, count= 10000).json()
|
||||
if messages["success"]:
|
||||
messages_recent += len(messages["messages"])
|
||||
nbMessages = len(messages["messages"])
|
||||
messages_recent += nbMessages
|
||||
channels_list.append((channel["name"], nbMessages))
|
||||
users.extend(map(lambda message: message["u"]["_id"], messages["messages"]))
|
||||
else:
|
||||
print("Error : {}".format(messages["error"]))
|
||||
|
||||
# Get the channels with the most number of message
|
||||
channels_list.sort(key=lambda channel: channel[1], reverse= True)
|
||||
channels_recentlist = list(map(lambda channel: channel[0], channels_list))
|
||||
|
||||
crapauds_recent = len(set(users))
|
||||
|
||||
info = {
|
||||
"crapauds": {
|
||||
"total": crapauds_total,
|
||||
|
@ -50,7 +60,8 @@ def main():
|
|||
"canaux": {
|
||||
"total": channels_total,
|
||||
"recent": channels_recent,
|
||||
"liste": channels_list
|
||||
# Get only the 10 first channels
|
||||
"liste": channels_recentlist[0:10]
|
||||
},
|
||||
"messages": {
|
||||
"total": messages_total,
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"crapauds": {"total": 2365, "recent": 0}, "canaux": {"total": 177, "recent": 99, "liste": ["accueil", "activite-et-travail", "agenda", "animation-crapauds", "audio-visuel-libre", "bnb-bonheur-national-brut", "bresil", "burn-out", "cercle-autonomie-energetique", "cercle-blockchain-crypto", "cercle-collaboratif", "cercle-des-arts", "cercle-d\u00e9mocratie", "cercle-education", "cercle-game-changers", "cercle-generation-2050", "cercle-intergenerationnel", "cercle-neurodiversit\u00e9", "cercle-permaculture", "cercle-sante", "changer-de-paradigme", "cohorte-2607", "cohorte-34", "cohorte-barcelone", "cohorte-belgique", "cohorte-bretagne", "cohorte-centre", "cohorte-geek", "cohorte-grece", "cohorte-grenoble", "cohorte-hdf", "cohorte-ile-de-france", "cohorte-loire", "cohorte-lyon-st-etienne", "cohorte-normandie", "cohorte-paca", "cohorte-scientifique", "cohorte-sud-ouest", "cohorte-suisse", "crapaud-fou-tv", "crapomobile", "desobeissance-civile", "dessins-citoyens-collectifs-booderies", "developpement-personnel", "doughnut-economics", "ecologie-biodiversite", "ecovillages-ecoquartiers", "education-populaire", "emancipation-outre-mer", "emmaus-pau-lescar", "empowerment", "energie", "faire-avancer-le-schmilblick-ecologique", "foret_bleue", "fou-a-lier", "general", "geopolitique", "gestion-de-l-eau", "gilets-jaunes", "how-to-low-tech", "info-desintox", "intelligence-artificielle", "intelligence-collective", "jeux-inde-1", "journee-univ-j-verne-nantes-4-juil-2019", "la-bascule-lobby-citoyen", "langage-vrai-anti-glossaire", "le-led", "lhomme-et-la-terre", "libre", "logiciel-libre", "meditation", "mutuelle-sociale-solidaire", "nature-simplicite-bienveillance", "no-gafam", "open-hardware", "p-2-p-dat", "philosophie", "pratiques-artistiques", "projet-cand-alterincub-centre", "psychologie-neurologie", "radio-crapaud", "recherches-biologie", "recueil-temoignages", "reflexion-sur-l-argent", "reflexion-sur-lamour", "rencontre-crapaud-kangourou", "right-to-repair", "semourais", "siteweb", "sociologie-de-l-effondrement", "solucracy", "survivalismes-et-resiliences", "terre-de-convergence", "tiers-lieux-apprenant", "tsunamis", "tvp-et-ebr", "wiki-crapaud-fou", "zero-dechet"]}, "messages": {"total": 186088, "recent": 13036}}
|
||||
{"crapauds": {"total": 2365, "recent": 181}, "canaux": {"total": 177, "recent": 99, "liste": ["semourais", "accueil", "general", "right-to-repair", "wiki-crapaud-fou", "cohorte-loire", "reflexion-sur-l-argent", "le-led", "empowerment", "libre"]}, "messages": {"total": 186095, "recent": 13043}}
|
|
@ -143,12 +143,12 @@
|
|||
<div class="recent">
|
||||
<div><span class="nombre crapauds">0</span> crapauds actifs</div>
|
||||
<div><span class="nombre canaux">0</span> canaux actifs</div>
|
||||
<div><span class="nombre messages">0</span> nouveaux messages</div>
|
||||
<div><span class="nombre messages">0</span> messages</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Les canaux les plus actifs sur 30 jours</div>
|
||||
<div>Les 10 canaux les plus actifs sur 30 jours</div>
|
||||
<div>
|
||||
<ul class="list">
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue