--- a/client/compteur.html Tue Feb 21 22:47:19 2012 +0100
+++ b/client/compteur.html Wed Feb 22 11:06:11 2012 +0100
@@ -39,7 +39,7 @@
/* Heure de début de l'émission
var startHour = new Date("Feb 24 2012 23:30:00 UTC+0100");
* */
- var startHour = new Date() - 120000;
+ var startHour = new Date() - 3600000;
/* Mots-clés pour déclencher la recherche
var searchKeywords = [ '#lgw', '#legrandwebze', 'webze' ];
@@ -47,16 +47,30 @@
var searchKeywords = ['Sarkozy', 'Hollande', 'Bayrou'];
var totalTweets = 0;
-
+
+ function getCounter() {
+ $.getJSON(serverUrl
+ + 'total/'
+ + Math.floor(startHour/1000)
+ + '?callback=?',
+ function(_data) {
+ totalTweets = _data.total;
+ });
+ }
+
$(function() {
- myTweetSource = new Btv_TweetSource({
- keywords: searchKeywords
- });
-
- myTweetSource.setOnNewTweets(function() {
- totalTweets = this.afterDate(startHour).count();
- });
+ if (typeof serverUrl == "undefined") {
+ myTweetSource = new Btv_TweetSource({
+ keywords: searchKeywords
+ });
+
+ myTweetSource.setOnNewTweets(function() {
+ totalTweets = this.afterDate(startHour).count();
+ });
+ } else {
+ setInterval(getCounter, 2000);
+ }
setInterval(function() {
var _aff = parseInt($("#nbtweets").html());
--- a/client/js/main.js Tue Feb 21 22:47:19 2012 +0100
+++ b/client/js/main.js Wed Feb 22 11:06:11 2012 +0100
@@ -109,6 +109,31 @@
});
}
+function updatePodiumAndLabels(_counts) {
+ myPodium.update(_counts);
+ $("#podium-chiffres").html(_counts.map(function(_c) {
+ return '<li>' + _c + '</li>'
+ }).join(""));
+}
+
+function getPodium() {
+ $.getJSON(serverUrl
+ + 'podium/'
+ + Math.floor(startHour/1000)
+ + '/'
+ + columnKeywords.map(function(_c) {
+ return encodeURIComponent(_c);
+ }).join(',')
+ + '?callback=?',
+ function(_data) {
+ var _counts = columnKeywords.map(function(_c) {
+ return _data.podium[_c] || 0;
+ });
+ $("#btv-cp-nb-tweets").html(_data.total);
+ updatePodiumAndLabels(_counts);
+ });
+}
+
$(function() {
columnCounts = columnKeywords.map(function() {
return 0;
@@ -124,6 +149,9 @@
}, 500);
myPodium = new Btv_Podium([0,0,0,0], { minHeight: 50 });
+ if (typeof serverUrl != "undefined") {
+ setInterval(getPodium, 2000);
+ }
$("#podium-labels").html(columnKeywords.map(function(_w) {
return '<li>' + _w + '</li>'
@@ -132,19 +160,17 @@
myTweetSource = new Btv_TweetSource({
keywords: searchKeywords
});
-
myTweetSource.setOnNewTweets(function() {
- var _filtered = this.afterDate(startHour);
- $("#btv-cp-nb-tweets").html(_filtered.count());
- var _counts = [];
- for (var _i = 0; _i < columnKeywords.length; _i++) {
- _counts.push(_filtered.search(columnKeywords[_i]).count());
+ updateLastTweetList();
+ if (typeof serverUrl == "undefined") {
+ var _filtered = this.afterDate(startHour);
+ $("#btv-cp-nb-tweets").html(_filtered.count());
+ var _counts = [];
+ for (var _i = 0; _i < columnKeywords.length; _i++) {
+ _counts.push(_filtered.search(columnKeywords[_i]).count());
+ }
+ updatePodiumAndLabels(_counts);
}
- updateLastTweetList();
- myPodium.update(_counts);
- $("#podium-chiffres").html(_counts.map(function(_c) {
- return '<li>' + _c + '</li>'
- }).join(""));
});
myQueueManager = new Btv_TweetQueueManager(myTweetSource, function(_t) {
var _cat = -1;
--- a/client/js/tweetsource.js Tue Feb 21 22:47:19 2012 +0100
+++ b/client/js/tweetsource.js Wed Feb 22 11:06:11 2012 +0100
@@ -196,7 +196,7 @@
Btv_TweetSource.prototype.retrieveInitialTweets = function() {
this.retrieveTweets({
- "pages": 4
+ "pages": 1
});
}
--- a/client/main.html Tue Feb 21 22:47:19 2012 +0100
+++ b/client/main.html Wed Feb 22 11:06:11 2012 +0100
@@ -26,13 +26,15 @@
/* Mots-clés pour déclencher la recherche
var searchKeywords = [ '#lgw', '#legrandwebze', 'webze' ];
* */
- var searchKeywords = ['Sarkozy', 'Hollande', 'Bayrou'];
+ var searchKeywords = ['Obama'];
/* Mots-clés correspondant aux colonnes
var columnKeywords = [ '#ilReste', '#ilPart', '#cQui', '#change2ton' ];
*/
- var columnKeywords = [ 'Hollande', 'Zorglub I°', 'Bayrou', 'Sarkozy' ];
+ var columnKeywords = [ 'Obama', '#tcot', '#p2', 'president' ];
+
+ var serverUrl = 'http://ftv.iri-research.org/a/';
</script>
</head>
--- a/server/web/tweetgserver/views.py Tue Feb 21 22:47:19 2012 +0100
+++ b/server/web/tweetgserver/views.py Wed Feb 22 11:06:11 2012 +0100
@@ -43,7 +43,7 @@
def podium(since, tokens):
sincetime = datetime.fromtimestamp(since)
token_list = tokens.split(",")
- query_base = db.session.query(func.count(Tweet.id)) #@UndefinedVariable
+ query_base = db.session.query(func.count(Tweet.id)).filter(Tweet.created_at >= sincetime) #@UndefinedVariable
podium_res = {}
for token in token_list:
query = query_base.filter(Tweet.text.op('~*')(token)) #@UndefinedVariable