-
-
Save imv7/dd9e22667c002328781d7058d8af1042 to your computer and use it in GitHub Desktop.
Live tweet and sentiment analysis with mongodb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"776762e3.b0eeac","type":"inject","z":"15c795ea.a10c9a","name":"Clear Tweets","topic":"","payload":"{}","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":420,"wires":[["27b036cc.2b2e1a"]]},{"id":"f58b9372.a60e","type":"mongodb out","z":"15c795ea.a10c9a","service":"_ext_","mongodb":"a0d6ddfe.1a9d","name":"","collection":"tweets","payonly":false,"upsert":false,"multi":false,"operation":"delete","x":683,"y":415,"wires":[]},{"id":"27b036cc.2b2e1a","type":"json","z":"15c795ea.a10c9a","name":"","x":385,"y":420,"wires":[["f58b9372.a60e"]]},{"id":"f101dd9a.668b9","type":"http response","z":"15c795ea.a10c9a","name":"","x":757,"y":345,"wires":[]},{"id":"443cc94a.cc8978","type":"twitter in","z":"15c795ea.a10c9a","twitter":"","tags":"#help","user":"false","name":"","topic":"tweets","x":215,"y":89,"wires":[["2cec1c50.952f14"]]},{"id":"2ca7f90.6e85308","type":"debug","z":"15c795ea.a10c9a","name":"","active":true,"console":"false","complete":"false","x":683,"y":93,"wires":[]},{"id":"df857e32.56dc1","type":"http in","z":"15c795ea.a10c9a","name":"","url":"/tweets","method":"get","swaggerDoc":"","x":190,"y":180,"wires":[["f10c50d1.0275a"]]},{"id":"ca07e21b.1c50b","type":"mongodb in","z":"15c795ea.a10c9a","service":"_ext_","mongodb":"a0d6ddfe.1a9d","name":"Retrieve Tweets","collection":"tweets","operation":"find","x":454,"y":277,"wires":[["bfcc41fd.f7a3b"]]},{"id":"bfcc41fd.f7a3b","type":"template","z":"15c795ea.a10c9a","name":"Styled Tweets","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n<head>\n <style>\nbody {\n text-align:center;\n}\nul {\n text-align:left;\n width: 500px;\n margin: auto;\n list-style-type:none;\n}\nli {\n border: 1px solid #999;\n border-left-width: 10px;\n border-radius: 3px;\n margin-bottom: 20px;\n padding: 10px;\n}\nli.sentiment_positive {\n border-left: 10px solid #69B369;\n}\nli.sentiment_negative {\n border-left: 10px solid #E64444;\n}\n.tweet {\n display: inline-block;\n font-family: Helvetica;\n width: 380px;\n margin-left: 10px;\n}\nimg {\n width: 48px;\n height: 48px;\n border-radius: 5px;\n vertical-align: top;\n}\n</style>\n\n</head>\n<body>\n\n<ul>\n{{#payload}}\n<li class=\"sentiment_{{sentiment.text}}\">\n <img src=\"{{tweet.user.profile_image_url}}\"/>\n <div class=\"tweet\">\n <div class=\"user\"><b>{{tweet.user.name}}</b> <small>@{{tweet.user.screen_name}}</small></div>\n <div class=\"text\">{{tweet.text}}</div>\n </div></li>\n{{/payload}}\n</ul>\n</body>\n</html>","output":"str","x":641,"y":297,"wires":[["f101dd9a.668b9"]]},{"id":"f10c50d1.0275a","type":"function","z":"15c795ea.a10c9a","name":"Limit/Sort","func":"msg.sort = {\"tweet.id\":-1};\nmsg.limit = 5;\nmsg.skip = 0;\nreturn msg;","outputs":1,"noerr":0,"x":356,"y":208,"wires":[["ca07e21b.1c50b"]]},{"id":"2cec1c50.952f14","type":"sentiment","z":"15c795ea.a10c9a","name":"","x":354,"y":89,"wires":[["abf9d643.a0ae18"]]},{"id":"abf9d643.a0ae18","type":"function","z":"15c795ea.a10c9a","name":"","func":"if(msg.sentiment.score > 0 ) {\n msg.sentiment.text = \"positive\";\n} else if (msg.sentiment.score < 0) {\n msg.sentiment.text = \"negative\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":491,"y":89,"wires":[["2ca7f90.6e85308","16b21a03.31b2e6"]]},{"id":"b4a14ef5.f2898","type":"template","z":"15c795ea.a10c9a","name":"Simple Tweet","field":"payload","format":"handlebars","template":"<ul>\n{{#payload}}\n <li>{{tweet.text}}</li>\n{{/payload}}\n</ul>","x":647,"y":233,"wires":[[]]},{"id":"16b21a03.31b2e6","type":"mongodb out","z":"15c795ea.a10c9a","service":"_ext_","mongodb":"a0d6ddfe.1a9d","name":"Save Tweets","collection":"tweets","payonly":false,"upsert":false,"multi":false,"operation":"store","x":681,"y":133,"wires":[]},{"id":"a0d6ddfe.1a9d","type":"mongodb","z":"","hostname":"127.0.0.1","port":"27017","db":"demo","name":""}] |
Author
imv7
commented
Oct 31, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment