Open rahulbot opened 6 years ago
Hmm... if we get this count in the results from the API we should probably show it. Perhaps next to the reply icon near the bottom of each content card? Putting this off as an enhancement we don't need urgently.
Currently count tweet replies is used to analyze virality, and going by the comments in the code, it seems to hit the rate limit quite often and hence is turned off for now. The implementation is in place but commented out to return 0 always.
`def count_tweet_replies(tweet):
# twitter_auth = TwitterAuth.query.filter_by(user_id=user_id).first()
# twitter = Twython(current_app.config['TWITTER_API_KEY'], current_app.config['TWITTER_API_SECRET'],
# twitter_auth.oauth_token, twitter_auth.oauth_token_secret)
# tweet_user_name = tweet['user']['screen_name']
# tweet_id = tweet['id_str']
# try:
# results = twitter.cursor(twitter.search, q='to:{}'.format(tweet_user_name), sinceId=tweet_id)
# count = len([1 for result in results if result['in_reply_to_status_id_str']==tweet_id])
# except:
# print 'error while counting tweet {} replies'.format(tweet_id)
# count = 0
count = 0
return count`
True. Twitter API does not have a way to get replies count for a tweet, so the only way of getting it (from reading various forums) is to use the search end point and search all tweets that are in reply to a specific tweet. This results in a lot of API calls that hit the rate limit.
When I read about it a few months ago there were many requests online to Twitter developers to add the replies count to the API so maybe they added it in the meantime?
On Tue, Jan 2, 2018, 12:20 rajaramsrinivas notifications@github.com wrote:
Currently count tweet replies is used to analyze virality, and going by the comments in the code, it seems to hit the rate limit quite often and hence is turned off for now. The implementation is in place but commented out to return 0 always.
def count_tweet_replies(tweet): #todo: this is getting to the API rate limit very quickly, find a better way to get replies count # twitter_auth = TwitterAuth.query.filter_by(user_id=user_id).first() # twitter = Twython(current_app.config['TWITTER_API_KEY'], current_app.config['TWITTER_API_SECRET'], # twitter_auth.oauth_token, twitter_auth.oauth_token_secret) # tweet_user_name = tweet['user']['screen_name'] # tweet_id = tweet['id_str'] # try: # results = twitter.cursor(twitter.search, q='to:{}'.format(tweet_user_name), sinceId=tweet_id) # count = len([1 for result in results if result['in_reply_to_status_id_str']==tweet_id]) # except: # print 'error while counting tweet {} replies'.format(tweet_id) # count = 0 count = 0 return count
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mitmedialab/gobo/issues/37#issuecomment-354820383, or mute the thread https://github.com/notifications/unsubscribe-auth/AIJMDHcNQDBYRjv7Uy52FAQwy7EZ5EVTks5tGmVZgaJpZM4RF5Hg .
Currently no. There is a stub method that always returns 0.
I'm not sure if we're using this data for any of the filters currently.