Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #336 from Rostlab/ranking
Browse files Browse the repository at this point in the history
Added d5 data to Ranking.jsx
  • Loading branch information
mammuth committed Apr 9, 2016
2 parents 894ba1c + 23dd236 commit c207c66
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 26 deletions.
72 changes: 57 additions & 15 deletions app/actions/TwitterSentimentsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});
Expand All @@ -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) {
Expand Down
20 changes: 18 additions & 2 deletions app/components/public/Ranking/Ranking.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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);
}
Expand All @@ -57,14 +61,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()
});
}

Expand Down
12 changes: 10 additions & 2 deletions app/constants/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_TALKED_ABOUT_SENTIMENTS: "RECEIVE_TWITTER_TALKED_ABOUT_SENTIMENTS",
RECEIVE_TWITTER_CHARACTER_SENTIMENT: "RECEIVE_TWITTER_CHARACTER_SENTIMENT"
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"
};
49 changes: 42 additions & 7 deletions app/stores/TwitterSentimentsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
},
Expand All @@ -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);
Expand Down

0 comments on commit c207c66

Please sign in to comment.