From 6b8ec397a75223d54b0effb38bc765b389557596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yasar=20K=C3=BCc=C3=BCkkaya?= Date: Fri, 8 Apr 2016 20:47:27 +0200 Subject: [PATCH 1/2] Added new constants for d5 integration --- app/constants/Constants.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/constants/Constants.js b/app/constants/Constants.js index f9bf6dd..5390a91 100644 --- a/app/constants/Constants.js +++ b/app/constants/Constants.js @@ -16,9 +16,17 @@ module.exports = { FILTER_FIELD_NAME: "name", FILTER_FIELD_HOUSE: "house", FILTER_FIELD_CULTURE: "culture", + + //d4 + RECEIVE_TWITTER_CHARACTER_SENTIMENT: "RECEIVE_TWITTER_CHARACTER_SENTIMENT", RECEIVE_TWITTER_TOP_SENTIMENTS: "RECEIVE_TWITTER_TOP_SENTIMENTS", RECEIVE_TWITTER_FLOP_SENTIMENTS: "RECEIVE_TWITTER_FLOP_SENTIMENTS", + RECEIVE_TWITTER_DISCUSSED_SENTIMENTS: "RECEIVE_TWITTER_DISCUSSED_SENTIMENTS", + + //d5 RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS: "RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS", + RECEIVE_TWITTER_TOP_SENTIMENTS: "RECEIVE_TWITTER_TOP_SENTIMENTS", + RECEIVE_TWITTER_WORST_CONTROVERSIAL_SENTIMENTS: "RECEIVE_TWITTER_WORST_CONTROVERSIAL_SENTIMENTS", RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS: "RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS", - RECEIVE_TWITTER_CHARACTER_SENTIMENT: "RECEIVE_TWITTER_CHARACTER_SENTIMENT" + RECEIVE_TWITTER_LISTEN_SENTIMENTS: "RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS" }; From 23dd2366f94db2b2536851ac24f18e5848819bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yasar=20K=C3=BCc=C3=BCkkaya?= Date: Fri, 8 Apr 2016 21:45:06 +0200 Subject: [PATCH 2/2] Added d5 data to Ranking.jsx --- app/actions/TwitterSentimentsActions.js | 72 ++++++++++++++++++----- app/components/public/Ranking/Ranking.jsx | 20 ++++++- app/constants/Constants.js | 6 +- app/stores/TwitterSentimentsStore.js | 49 ++++++++++++--- 4 files changed, 120 insertions(+), 27 deletions(-) diff --git a/app/actions/TwitterSentimentsActions.js b/app/actions/TwitterSentimentsActions.js index 9c17432..090f821 100644 --- a/app/actions/TwitterSentimentsActions.js +++ b/app/actions/TwitterSentimentsActions.js @@ -24,26 +24,12 @@ var TwitterSentimentsActions = { }); }); }, - loadControversialSentiments: function(count,startDate,endDate) { - Api - .get('d5/sentiment/controversial',{ - number: count, - startDate: startDate, - endDate: endDate - }) - .then(function (sentiments) { - AppDispatcher.handleServerAction({ - actionType: Constants.RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS, - data: sentiments - }); - }); - }, loadMostDiscussedSentiments: function(count) { Api .get('d4/sentiment/discussed', {number: count}) .then(function (sentiments) { AppDispatcher.handleServerAction({ - actionType: Constants.RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS, + actionType: Constants.RECEIVE_TWITTER_DISCUSSED_SENTIMENTS, data: sentiments }); }); @@ -57,6 +43,62 @@ var TwitterSentimentsActions = { data: sentiments }); }); + }, + + loadControversialSentiments: function(count,startDate,endDate) { + Api + .get('d5/sentiment/controversial',{ + number: count, + startDate: startDate, + endDate: endDate + }) + .then(function (sentiments) { + AppDispatcher.handleServerAction({ + actionType: Constants.RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS, + data: sentiments + }); + }); + }, + loadTopSentiments_d5: function(count,startDate,endDate) { + Api + .get('d5/sentiment/top',{ + number: count, + startDate: startDate, + endDate: endDate}) + .then(function (sentiments) { + AppDispatcher.handleServerAction({ + actionType: Constants.RECEIVE_TWITTER_TOP_SENTIMENTS_D5, + data: sentiments + }); + }); + }, + loadFlopSentiments_d5: function(count,startDate,endDate) { + Api + .get('d5/sentiment/worst',{ + number: count, + startDate: startDate, + endDate: endDate + }) + .then(function (sentiments) { + AppDispatcher.handleServerAction({ + actionType: Constants.RECEIVE_TWITTER_FLOP_SENTIMENTS_D5, + data: sentiments + }); + }); + }, + loadMostDiscussedSentiments_d5: function(count,startDate,endDate) { + Api + .get('d5/sentiment/talked', { + number: count, + startDate: startDate, + endDate: endDate + }) + .then(function (sentiments) { + AppDispatcher.handleServerAction({ + actionType: Constants.RECEIVE_TWITTER_DISCUSSED_SENTIMENTS_D5, + data: sentiments + }); + }); } // , // loadCharacterSentimentByTimeframe: function(name,startDate,endDate) { diff --git a/app/components/public/Ranking/Ranking.jsx b/app/components/public/Ranking/Ranking.jsx index 6dc63ca..af7e104 100644 --- a/app/components/public/Ranking/Ranking.jsx +++ b/app/components/public/Ranking/Ranking.jsx @@ -33,7 +33,11 @@ export default class Ranking extends Component { this.state = { twitterTopSentiments: [], twitterFlopSentiments: [], - twitterTopControversial: [] + twitterMostDiscussedSentiments: [], + twitterTopControversial: [], + twitterTopSentiments_d5: [], + twitterFlopSentiments_d5: [], + twitterMostDiscussedSentiments_d5: [] }; this._onChange = this._onChange.bind(this); } @@ -48,14 +52,26 @@ export default class Ranking extends Component { componentDidMount() { + const startDate = (new Date(1995, 11, 17)).toISOString(); + const today = (new Date()).toISOString(); SentimentsActions.loadTopSentiments(5); SentimentsActions.loadFlopSentiments(5); + SentimentsActions.loadMostDiscussedSentiments(5); + SentimentsActions.loadControversialSentiments(5, startDate , today); + SentimentsActions.loadTopSentiments_d5(5, startDate , today); + SentimentsActions.loadFlopSentiments_d5(5, startDate , today); + SentimentsActions.loadMostDiscussedSentiments_d5(5, startDate , today); } _onChange() { this.setState({ twitterTopSentiments: SentimentStore.getTopSentiments(), - twitterFlopSentiments: SentimentStore.getFlopSentiments() + twitterFlopSentiments: SentimentStore.getFlopSentiments(), + twitterMostDiscussedSentiments: SentimentStore.getMostDiscussedSentiments(), + twitterTopControversial: SentimentStore.getFlopSentiments(), + twitterTopSentiments_d5: SentimentStore.getTopSentiments_d5(), + twitterFlopSentiments_d5: SentimentStore.getFlopSentiments_d5(), + twitterMostDiscussedSentiments_d5: SentimentStore.getMostDiscussedSentiments_d5() }); } diff --git a/app/constants/Constants.js b/app/constants/Constants.js index 5390a91..980e99d 100644 --- a/app/constants/Constants.js +++ b/app/constants/Constants.js @@ -25,8 +25,8 @@ module.exports = { //d5 RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS: "RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS", - RECEIVE_TWITTER_TOP_SENTIMENTS: "RECEIVE_TWITTER_TOP_SENTIMENTS", - RECEIVE_TWITTER_WORST_CONTROVERSIAL_SENTIMENTS: "RECEIVE_TWITTER_WORST_CONTROVERSIAL_SENTIMENTS", - RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS: "RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS", + RECEIVE_TWITTER_TOP_SENTIMENTS_D5: "RECEIVE_TWITTER_TOP_SENTIMENTS_D5", + RECEIVE_TWITTER_FLOP_SENTIMENTS_D5: "RECEIVE_TWITTER_FLOP_SENTIMENTS_D5", + RECEIVE_TWITTER_DISCUSSED_SENTIMENTS_D5: "RECEIVE_TWITTER_DISCUSSED_SENTIMENTS_D5", RECEIVE_TWITTER_LISTEN_SENTIMENTS: "RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS" }; diff --git a/app/stores/TwitterSentimentsStore.js b/app/stores/TwitterSentimentsStore.js index c7bcc87..3157f35 100644 --- a/app/stores/TwitterSentimentsStore.js +++ b/app/stores/TwitterSentimentsStore.js @@ -6,18 +6,22 @@ var assign = require('object-assign'); var _topSentiments = []; var _flopSentiments = []; -var _mostTalkedAboutSentiments = []; +var _mostDiscussedSentiments = []; var _topControversialSentiments = []; var _characterSentiment = {}; +var _topSentiments_d5 = []; +var _flopSentiments_d5 = []; +var _mostDiscussedSentiments_d5 = []; + function setTopSentiments(data) { _topSentiments = data; } function setFlopSentiments(data) { _flopSentiments = data; } -function setMostTalkedAboutSentiments(data) { - _mostTalkedAboutSentiments = data; +function setMostDiscussedSentiments(data) { + _mostDiscussedSentiments = data; } function setTopControversialSentiments(data) { _topControversialSentiments = data; @@ -26,6 +30,16 @@ function setTopControversialSentiments(data) { function setCharacterSentiment(data) { _characterSentiment = data; } +function setTopSentiments_d5(data) { + _topSentiments_d5 = data; +} +function setFlopSentiments_d5(data) { + _flopSentiments_d5 = data; +} +function setMostDiscussedSentiments_d5(data) { + _mostDiscussedSentiments_d5 = data; +} + // Merge our store with Node's Event Emitter @@ -39,14 +53,26 @@ var TwitterSentimentsStore = assign({}, EventEmitter.prototype, { return _flopSentiments; }, - getMostTalkedAboutSentiments: function() { - return _mostTalkedAboutSentiments; + getMostDiscussedSentiments: function() { + return _mostDiscussedSentiments; }, getTopControversialSentiments: function() { return _topControversialSentiments; }, + getTopSentiments_d5: function() { + return _topSentiments_d5; + }, + + getFlopSentiments_d5: function() { + return _flopSentiments_d5; + }, + + getMostDiscussedSentiments_d5: function() { + return _mostDiscussedSentiments_d5; + }, + getCharacterSentiment: function() { return _characterSentiment; }, @@ -72,14 +98,23 @@ TwitterSentimentsStore.dispatchToken = AppDispatcher.register(function (payload) case Constants.RECEIVE_TWITTER_CONTROVERSIAL_SENTIMENTS: setTopControversialSentiments(action.data); break; + case Constants.RECEIVE_TWITTER_TOP_SENTIMENTS_D5: + setTopSentiments_d5(action.data); + break; + case Constants.RECEIVE_TWITTER_FLOP_SENTIMENTS_D5: + setFlopSentiments_d5(action.data); + break; + case Constants.RECEIVE_TWITTER_DISCUSSED_SENTIMENTS_D5: + setMostDiscussedSentiments_d5(action.data); + break; case Constants.RECEIVE_TWITTER_FLOP_SENTIMENTS: setFlopSentiments(action.data); break; case Constants.RECEIVE_TWITTER_TOP_SENTIMENTS: setTopSentiments(action.data); break; - case Constants.RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS: - setMostTalkedAboutSentiments(action.data); + case Constants.RECEIVE_TWITTER_DISCUSSED_SENTIMENTS: + setMostDiscussedSentiments(action.data); break; case Constants.RECEIVE_TWITTER_CHARACTER_SENTIMENT: setCharacterSentiment(action.data);