{"id":1425,"date":"2020-12-09T22:53:52","date_gmt":"2020-12-09T21:53:52","guid":{"rendered":"https:\/\/hannes.enjoys.it\/blog\/?p=1425"},"modified":"2020-12-09T22:53:52","modified_gmt":"2020-12-09T21:53:52","slug":"finding-the-most-popular-reaction-in-slack","status":"publish","type":"post","link":"https:\/\/hannes.enjoys.it\/blog\/2020\/12\/finding-the-most-popular-reaction-in-slack\/","title":{"rendered":"Finding the most popular reaction in Slack"},"content":{"rendered":"\n<p>This can be run against a Slack export. It will count the reactions used and display them in an ordered list. Written for readability not speed or efficiency. No guarantees that this isn&#8217;t terribly broken. Enjoy and use responsibly!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import json\nimport glob\nimport collections\n\n# collect messages\nmessages = &#91;]\nfor filename in glob.glob('*\/*.json'):\n    with open(filename) as f:\n        messages += json.load(f)\n\n# extract reactions\nreactions = &#91;]\nfor message in messages:\n    if \"reactions\" in message:\n        reactions += message&#91;\"reactions\"]\n\n# count reactions\nreaction_counter = collections.Counter()\nfor reaction in reactions:\n    reaction_counter.update({reaction&#91;\"name\"]: reaction&#91;\"count\"]})\n\n# done, print them\nprint(reaction_counter.most_common())<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This can be run against a Slack export. It will count the reactions used and display them in an ordered list. Written for readability not speed or efficiency. No guarantees that this isn&#8217;t terribly broken. Enjoy and use responsibly!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,40],"tags":[],"class_list":["post-1425","post","type-post","status-publish","format-standard","hentry","category-python","category-small-things"],"_links":{"self":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/comments?post=1425"}],"version-history":[{"count":1,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1425\/revisions"}],"predecessor-version":[{"id":1426,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1425\/revisions\/1426"}],"wp:attachment":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/media?parent=1425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/categories?post=1425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/tags?post=1425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}