def create_rtvt_aio_plot(self, tweets, retweets):

        tweet_coords = Tweets.tweets_per_minute(tweets)
        retweet_coords = Retweets.retweets_per_minute(retweets)

        tweet_coords.sort(key=lambda x: int(x[1]), reverse=True)
        retweet_coords.sort(key=lambda x: int(x[1]), reverse=True)

        return Graphs.rtwt_vs_twt_24h(retweet_coords, tweet_coords, __class__)
    def user_data_box(self, tweets, retweets, statuses):

        tweepy_data = User.get_user_data_tweepy(self)

        account_created = tweepy_data[0]
        total_followers = tweepy_data[1]
        total_friends = tweepy_data[2]
        total_statuses = tweepy_data[3]
        geo_status = tweepy_data[4]
        screen_name = tweepy_data[5]

        # num of user's tweets in db
        total_on_record = len(statuses)

        # percentage of user's total tweets in db
        coverage = round(((len(statuses) / total_statuses) * 100), 2)
        coverage = str(coverage) + '%'

        # Users top 10 most mentioned users
        user_mentions = list(Mentions.users_mentioned(tweets)[1])
        user_mentions = sorted(user_mentions,
                               key=lambda x: int(x[1]),
                               reverse=True)
        user_mentions = user_mentions[:10]

        # top 10 hashtags used
        user_hashtags = Hashtags.get_user_hashtags(tweets)[0]
        top_hash = list(Hashtags.count_hashtags(user_hashtags))
        top_hash = sorted(top_hash, key=lambda x: int(x[1]), reverse=True)
        top_hash = top_hash[:10]

        # Users top 10 most retweeted users
        users_retweeted = Retweets.get_retweeted_users(retweets)
        users_retweeted = users_retweeted[0]

        count_retweeted = list(
            set([(x, users_retweeted.count(x)) for x in users_retweeted]))
        fav_retweeted = sorted(count_retweeted,
                               key=lambda x: int(x[1]),
                               reverse=True)
        fav_retweeted = fav_retweeted[:10]

        first_on_record = statuses[0]
        most_recent_on_record = statuses[-1]

        # favourite tweet time
        fav_time = Tweets.tweets_per_minute(statuses)
        fav_time = sorted(fav_time, key=lambda x: int(x[1]), reverse=True)
        fav_time = fav_time[0]

        # day with most statuses sent
        busy_day = Tweets.tweets_per_date(statuses)
        busy_day = sorted(busy_day, key=lambda x: int(x[1]), reverse=True)
        busy_day = busy_day[0]

        # most used medium to tweet
        sources = [i[4] for i in statuses]
        fav_source = Sources.counted_sources(sources)
        fav_source = sorted(fav_source, key=lambda x: int(x[1]), reverse=True)
        fav_source = fav_source[0]

        return (screen_name, account_created, total_statuses, total_on_record,
                total_followers, total_friends, geo_status, first_on_record,
                most_recent_on_record, coverage, top_hash, fav_retweeted,
                user_mentions, fav_time, busy_day, fav_source)
Exemple #3
0
    def create_aio_plot(tweet_list):

        graph_coords = Tweets.tweets_per_minute(tweet_list)
        graph_coords.sort(key=lambda x: int(x[1]), reverse=True)

        return Graphs.all_in_one(graph_coords, __class__)