various small adjustments, renaming tsunamis by topics because we gonna extend it to the categories at some point
This commit is contained in:
parent
24016d2f2a
commit
e8dc51b0ce
8 changed files with 124 additions and 120 deletions
|
@ -13,32 +13,32 @@ def createElement(label, color, data) :
|
||||||
"data": data
|
"data": data
|
||||||
}
|
}
|
||||||
|
|
||||||
def setTsunamyInfo(tsunamy, messagesDataTsunamy, id, length):
|
def setTopicInfo(tsunamy, messagesDataTopic, id, length):
|
||||||
if tsunamy & Tsunami.GLOBAL:
|
if tsunamy & Topics.GLOBAL:
|
||||||
messagesDataTsunamy[Tsunami.GLOBAL][id] += length
|
messagesDataTopic[Topics.GLOBAL][id] += length
|
||||||
if tsunamy & Tsunami.PROJECT:
|
if tsunamy & Topics.PROJECT:
|
||||||
messagesDataTsunamy[Tsunami.PROJECT][id] += length
|
messagesDataTopic[Topics.PROJECT][id] += length
|
||||||
if tsunamy & Tsunami.DEMOCRACY:
|
if tsunamy & Topics.DEMOCRACY:
|
||||||
messagesDataTsunamy[Tsunami.DEMOCRACY][id] += length
|
messagesDataTopic[Topics.DEMOCRACY][id] += length
|
||||||
if tsunamy & Tsunami.ECOLOGY:
|
if tsunamy & Topics.ECOLOGY:
|
||||||
messagesDataTsunamy[Tsunami.ECOLOGY][id] += length
|
messagesDataTopic[Topics.ECOLOGY][id] += length
|
||||||
if tsunamy & Tsunami.TECHNOLOGY:
|
if tsunamy & Topics.TECHNOLOGY:
|
||||||
messagesDataTsunamy[Tsunami.TECHNOLOGY][id] += length
|
messagesDataTopic[Topics.TECHNOLOGY][id] += length
|
||||||
|
|
||||||
def getTsunamy(channel):
|
def getTopic(channel):
|
||||||
value = Tsunami.GLOBAL
|
value = Topics.GLOBAL
|
||||||
if 'description' in channel:
|
if 'description' in channel:
|
||||||
if channel['description'].find("#projet") != -1:
|
if channel['description'].find("#projet") != -1:
|
||||||
value |= Tsunami.PROJECT
|
value |= Topics.PROJECT
|
||||||
if channel['description'].find("#democratie") != -1:
|
if channel['description'].find("#democratie") != -1:
|
||||||
value |= Tsunami.DEMOCRACY
|
value |= Topics.DEMOCRACY
|
||||||
if channel['description'].find("#ecologie") != -1:
|
if channel['description'].find("#ecologie") != -1:
|
||||||
value |= Tsunami.ECOLOGY
|
value |= Topics.ECOLOGY
|
||||||
if channel['description'].find("#technologie") != -1:
|
if channel['description'].find("#technologie") != -1:
|
||||||
value |= Tsunami.TECHNOLOGY
|
value |= Topics.TECHNOLOGY
|
||||||
return value
|
return value
|
||||||
|
|
||||||
class Tsunami:
|
class Topics:
|
||||||
GLOBAL = 1 << 0
|
GLOBAL = 1 << 0
|
||||||
PROJECT = 1 << 1
|
PROJECT = 1 << 1
|
||||||
DEMOCRACY = 1 << 2
|
DEMOCRACY = 1 << 2
|
||||||
|
|
|
@ -11,7 +11,7 @@ import random
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from common.rocketchathelper import getAllChannels, getAllMessages, Connection
|
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, setTopicInfo, getTopic, Topics
|
||||||
|
|
||||||
begin = datetime.now()
|
begin = datetime.now()
|
||||||
end = datetime.now()
|
end = datetime.now()
|
||||||
|
@ -25,12 +25,12 @@ def main():
|
||||||
labels = [None] * nbElements
|
labels = [None] * nbElements
|
||||||
messagesByChannel = []
|
messagesByChannel = []
|
||||||
usersByChannel = []
|
usersByChannel = []
|
||||||
messagesDataTsunamy = {
|
messagesDataTopic = {
|
||||||
Tsunami.GLOBAL: [0] * nbElements,
|
Topics.GLOBAL: [0] * nbElements,
|
||||||
Tsunami.PROJECT: [0] * nbElements,
|
Topics.PROJECT: [0] * nbElements,
|
||||||
Tsunami.DEMOCRACY: [0] * nbElements,
|
Topics.DEMOCRACY: [0] * nbElements,
|
||||||
Tsunami.ECOLOGY: [0] * nbElements,
|
Topics.ECOLOGY: [0] * nbElements,
|
||||||
Tsunami.TECHNOLOGY: [0] * nbElements,
|
Topics.TECHNOLOGY: [0] * nbElements,
|
||||||
}
|
}
|
||||||
usersGlobal = []
|
usersGlobal = []
|
||||||
|
|
||||||
|
@ -38,16 +38,16 @@ def main():
|
||||||
date = datetime(now.year, now.month, now.day, 0,0,0)
|
date = datetime(now.year, now.month, now.day, 0,0,0)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
"updated": "updated {:02}/{:02}/{:04}".format(now.day, now.month, now.year),
|
"updated": "{:02}/{:02}/{:04}".format(now.day, now.month, now.year),
|
||||||
"labels": labels,
|
"labels": labels,
|
||||||
"messagesByChannel": messagesByChannel,
|
"messagesByChannel": messagesByChannel,
|
||||||
"usersByChannel": usersByChannel,
|
"usersByChannel": usersByChannel,
|
||||||
"messagesByTsunamy": [
|
"messagesByTopic": [
|
||||||
createElement("global", getColor(), messagesDataTsunamy[Tsunami.GLOBAL]),
|
createElement("global", getColor(), messagesDataTopic[Topics.GLOBAL]),
|
||||||
createElement("project", getColor(), messagesDataTsunamy[Tsunami.PROJECT]),
|
createElement("project", getColor(), messagesDataTopic[Topics.PROJECT]),
|
||||||
createElement("democratie", getColor(), messagesDataTsunamy[Tsunami.DEMOCRACY]),
|
createElement("democratie", getColor(), messagesDataTopic[Topics.DEMOCRACY]),
|
||||||
createElement("ecologie", getColor(), messagesDataTsunamy[Tsunami.ECOLOGY]),
|
createElement("ecologie", getColor(), messagesDataTopic[Topics.ECOLOGY]),
|
||||||
createElement("technologie", getColor(), messagesDataTsunamy[Tsunami.TECHNOLOGY])
|
createElement("technologie", getColor(), messagesDataTopic[Topics.TECHNOLOGY])
|
||||||
],
|
],
|
||||||
"usersGlobal": usersGlobal
|
"usersGlobal": usersGlobal
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ def main():
|
||||||
begin = date - timedelta(nbElements)
|
begin = date - timedelta(nbElements)
|
||||||
end = begin + timedelta(nbElements)
|
end = begin + timedelta(nbElements)
|
||||||
|
|
||||||
tsunamy = getTsunamy(channel)
|
tsunamy = getTopic(channel)
|
||||||
|
|
||||||
messages = getAllMessages(rocket, channel['_id'], begindate= begin, enddate= end, count= channel["msgs"])
|
messages = getAllMessages(rocket, channel['_id'], begindate= begin, enddate= end, count= channel["msgs"])
|
||||||
end = begin + timedelta(1)
|
end = begin + timedelta(1)
|
||||||
|
@ -77,7 +77,7 @@ def main():
|
||||||
dataMess.append(length)
|
dataMess.append(length)
|
||||||
|
|
||||||
if length > 0:
|
if length > 0:
|
||||||
setTsunamyInfo(tsunamy, messagesDataTsunamy, id, length)
|
setTopicInfo(tsunamy, messagesDataTopic, id, length)
|
||||||
|
|
||||||
users = []
|
users = []
|
||||||
for mess in resultMess:
|
for mess in resultMess:
|
||||||
|
|
|
@ -12,7 +12,7 @@ from datetime import datetime
|
||||||
from monthdelta import monthdelta
|
from monthdelta import monthdelta
|
||||||
from common.rocketchathelper import getAllChannels, getAllMessages, Connection
|
from common.rocketchathelper import getAllChannels, getAllMessages, Connection
|
||||||
from common.savehelper import save
|
from common.savehelper import save
|
||||||
from common.charthelper import createElement, getColor, setTsunamyInfo, Tsunami, getTsunamy
|
from common.charthelper import createElement, getColor, setTopicInfo, Topics, getTopic
|
||||||
|
|
||||||
begin = datetime.now()
|
begin = datetime.now()
|
||||||
end = datetime.now()
|
end = datetime.now()
|
||||||
|
@ -26,12 +26,12 @@ def main():
|
||||||
labels = [None] * 12
|
labels = [None] * 12
|
||||||
messagesByChannel = []
|
messagesByChannel = []
|
||||||
usersByChannel = []
|
usersByChannel = []
|
||||||
messagesDataTsunamy = {
|
messagesDataTopic = {
|
||||||
Tsunami.GLOBAL: [0] * 12,
|
Topics.GLOBAL: [0] * 12,
|
||||||
Tsunami.PROJECT: [0] * 12,
|
Topics.PROJECT: [0] * 12,
|
||||||
Tsunami.DEMOCRACY: [0] * 12,
|
Topics.DEMOCRACY: [0] * 12,
|
||||||
Tsunami.ECOLOGY: [0] * 12,
|
Topics.ECOLOGY: [0] * 12,
|
||||||
Tsunami.TECHNOLOGY: [0] * 12,
|
Topics.TECHNOLOGY: [0] * 12,
|
||||||
}
|
}
|
||||||
usersGlobal = []
|
usersGlobal = []
|
||||||
|
|
||||||
|
@ -39,16 +39,16 @@ def main():
|
||||||
date = datetime(now.year, now.month, now.day, 0,0,0)
|
date = datetime(now.year, now.month, now.day, 0,0,0)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
"updated": "updated {:02}/{:02}/{:04}".format(now.day, now.month, now.year),
|
"updated": "{:02}/{:02}/{:04}".format(now.day, now.month, now.year),
|
||||||
"labels": labels,
|
"labels": labels,
|
||||||
"messagesByChannel": messagesByChannel,
|
"messagesByChannel": messagesByChannel,
|
||||||
"usersByChannel": usersByChannel,
|
"usersByChannel": usersByChannel,
|
||||||
"messagesByTsunamy": [
|
"messagesByTopic": [
|
||||||
createElement("global", getColor(), messagesDataTsunamy[Tsunami.GLOBAL]),
|
createElement("global", getColor(), messagesDataTopic[Topics.GLOBAL]),
|
||||||
createElement("project", getColor(), messagesDataTsunamy[Tsunami.PROJECT]),
|
createElement("project", getColor(), messagesDataTopic[Topics.PROJECT]),
|
||||||
createElement("democratie", getColor(), messagesDataTsunamy[Tsunami.DEMOCRACY]),
|
createElement("democratie", getColor(), messagesDataTopic[Topics.DEMOCRACY]),
|
||||||
createElement("ecologie", getColor(), messagesDataTsunamy[Tsunami.ECOLOGY]),
|
createElement("ecologie", getColor(), messagesDataTopic[Topics.ECOLOGY]),
|
||||||
createElement("technologie", getColor(), messagesDataTsunamy[Tsunami.TECHNOLOGY])
|
createElement("technologie", getColor(), messagesDataTopic[Topics.TECHNOLOGY])
|
||||||
],
|
],
|
||||||
"usersGlobal": usersGlobal
|
"usersGlobal": usersGlobal
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ def main():
|
||||||
|
|
||||||
messages = getAllMessages(rocket, channel['_id'], begindate= begin, enddate=date, count= channel['msgs'])
|
messages = getAllMessages(rocket, channel['_id'], begindate= begin, enddate=date, count= channel['msgs'])
|
||||||
|
|
||||||
tsunamy = getTsunamy(channel)
|
tsunamy = getTopic(channel)
|
||||||
|
|
||||||
for id in range(0, 12):
|
for id in range(0, 12):
|
||||||
if uniqueUserGlobal[id] == None:
|
if uniqueUserGlobal[id] == None:
|
||||||
|
@ -77,7 +77,7 @@ def main():
|
||||||
dataMess.append(length)
|
dataMess.append(length)
|
||||||
|
|
||||||
if length > 0:
|
if length > 0:
|
||||||
setTsunamyInfo(tsunamy, messagesDataTsunamy, id, length)
|
setTopicInfo(tsunamy, messagesDataTopic, id, length)
|
||||||
|
|
||||||
users = []
|
users = []
|
||||||
for mess in resultMess:
|
for mess in resultMess:
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<a href="/"><img src="images/crapovecto_small.svg" height="100" class="float-left logo" /></a>
|
<a href="index.html"><img src="images/crapovecto_small.svg" height="100" class="float-left logo" /></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<canvas id="byChannel"></canvas>
|
<canvas id="byChannel"></canvas>
|
||||||
<canvas id="byTsunamy"></canvas>
|
<canvas id="byTopic"></canvas>
|
||||||
<canvas id="usersByChannel"></canvas>
|
<canvas id="usersByChannel"></canvas>
|
||||||
<canvas id="usersGlobal"></canvas>
|
<canvas id="usersGlobal"></canvas>
|
||||||
<canvas id="byChannel_daily"></canvas>
|
<canvas id="byChannel_daily"></canvas>
|
||||||
<canvas id="byTsunamy_daily"></canvas>
|
<canvas id="byTopic_daily"></canvas>
|
||||||
<canvas id="usersByChannel_daily"></canvas>
|
<canvas id="usersByChannel_daily"></canvas>
|
||||||
<canvas id="usersGlobal_daily"></canvas>
|
<canvas id="usersGlobal_daily"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|
100
site/coastats.js
100
site/coastats.js
|
@ -1,55 +1,59 @@
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$.getJSON("data/chat_stat_monthly.json", function (data) {
|
|
||||||
updated = data.updated;
|
$.getJSON("data/chat_stat_monthly.json", function (data) {
|
||||||
labels = data.labels;
|
updated = "mise à jour " + data.updated;
|
||||||
graphDisplay($('#byChannel'), data.messagesByChannel, "Nombre de messages par canal sur 1 an (" + updated + ")");
|
labels = data.labels;
|
||||||
graphDisplay($('#byTsunamy'), data.messagesByTsunamy, "Nombre de messages par Tsunami sur 1 an (" + updated + ")");
|
console.log(data);
|
||||||
graphDisplay($("#usersByChannel"), data.usersByChannel, "Nombre d'utilisateurs actifs par canal sur 1 an (" + updated + ")");
|
graphDisplay($('#byChannel'), data.messagesByChannel, "Nombre de messages par canal sur 1 an (" + updated + ")");
|
||||||
graphDisplay($("#usersGlobal"), data.usersGlobal, "Nombre d'utilisateurs actifs sur 1 an (" + updated + ")");
|
graphDisplay($('#byTopic'), data.messagesByTopic, "Nombre de messages par thème sur 1 an (" + updated + ")");
|
||||||
});
|
graphDisplay($("#usersByChannel"), data.usersByChannel, "Nombre d'utilisateurs actifs par canal sur 1 an (" + updated + ")");
|
||||||
$.getJSON("data/chat_stat_daily.json", function (data) {
|
graphDisplay($("#usersGlobal"), data.usersGlobal, "Nombre d'utilisateurs actifs sur 1 an (" + updated + ")");
|
||||||
updated = data.updated;
|
});
|
||||||
labels = data.labels;
|
|
||||||
graphDisplay($('#byChannel_daily'), data.messagesByChannel, "Nombre de messages par canal sur 30 jours (" + updated + ")");
|
$.getJSON("data/chat_stat_daily.json", function (data) {
|
||||||
graphDisplay($('#byTsunamy_daily'), data.messagesByTsunamy, "Nombre de messages par Tsunami sur 30 jours (" + updated + ")");
|
updated = "mise à jour " + data.updated;
|
||||||
graphDisplay($("#usersByChannel_daily"), data.usersByChannel, "Nombre d'utilisateurs actifs par canal sur 30 jours (" + updated + ")");
|
labels = data.labels;
|
||||||
graphDisplay($("#usersGlobal_daily"), data.usersGlobal, "Nombre d'utilisateurs actifs sur 30 jours (" + updated + ")");
|
graphDisplay($('#byChannel_daily'), data.messagesByChannel, "Nombre de messages par canal sur 30 jours (" + updated + ")");
|
||||||
});
|
graphDisplay($('#byTopic_daily'), data.messagesByTopic, "Nombre de messages par thème sur 30 jours (" + updated + ")");
|
||||||
|
graphDisplay($("#usersByChannel_daily"), data.usersByChannel, "Nombre d'utilisateurs actifs par canal sur 30 jours (" + updated + ")");
|
||||||
|
graphDisplay($("#usersGlobal_daily"), data.usersGlobal, "Nombre d'utilisateurs actifs sur 30 jours (" + updated + ")");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function graphDisplay(ctx, data, title) {
|
function graphDisplay(ctx, data, title) {
|
||||||
new Chart(ctx, {
|
new Chart(ctx, {
|
||||||
// The type of chart we want to create
|
// The type of chart we want to create
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
|
|
||||||
// The data for our dataset
|
// The data for our dataset
|
||||||
data: {
|
data: {
|
||||||
labels: labels,
|
labels: labels,
|
||||||
datasets: data,
|
datasets: data,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Configuration options go here
|
// Configuration options go here
|
||||||
options: {
|
options: {
|
||||||
legend: {
|
legend: {
|
||||||
display: false
|
display: false
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: title,
|
text: title,
|
||||||
position: "top"
|
position: "top"
|
||||||
},
|
},
|
||||||
responsive: true,
|
responsive: true,
|
||||||
scales: {
|
scales: {
|
||||||
xAxes: [{
|
xAxes: [{
|
||||||
stacked: true
|
stacked: true
|
||||||
}],
|
}],
|
||||||
yAxes: [{
|
yAxes: [{
|
||||||
stacked: true,
|
stacked: true,
|
||||||
ticks: {
|
ticks: {
|
||||||
stepSize: 500
|
stepSize: 500
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,19 +1,19 @@
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "Les Crapauds fous",
|
||||||
"short_name": "",
|
"short_name": "Crapauds Fous",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "android-chrome-192x192.png",
|
"src": "android-chrome-192x192.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "android-chrome-512x512.png",
|
"src": "android-chrome-512x512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"theme_color": "#ffffff",
|
"theme_color": "#ffffff",
|
||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"display": "standalone"
|
"display": "standalone"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue