Skip to content

Instantly share code, notes, and snippets.

@yurukov
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurukov/9f728767ca9bb9945ee2 to your computer and use it in GitHub Desktop.
Save yurukov/9f728767ca9bb9945ee2 to your computer and use it in GitHub Desktop.
Algo for RT tweets in @GivAlertEU
This is a an abstract description of the loopback algorythm that @govalerteu uses to RT tweets from a selection of accounts.
The database keeps a list of all the accounts that are monitored with the timestamp of the last RT and check (run of this algo), the number of all tweets that were RT and the sum of their RT and fav.
For each account on regular intervals:
1. List all the tweets since the last check
2. Exclude all that are newer than 2 hours
3. Exclude all the answers
4. Sort them in 3 categories - tweets in Bulgarian, tweets mentioning Bulgaria and others. Sort these categories by the number of RTs and then by the number of fav.
5. Get the one on the top and check if it has more fav+RT than 2/3 of the average of those RT-ed until now for this account, but not less than 3. If the account hasn't been retweeted for over 4 days and 2 hours, RT the top tweet if it has more than 3 RT+fav.
6. Add the number of RT and fav to the database to be used in the next check.
7. RT the tweet.
The algo will RT any tweet that is among the most popular giving priority to those in Bulgaria and mentioning Bulgaria. The RT and fav of the RTedvtweets feed back in the average score. Thus growing or decreasing popularity of that person is accounted for. A drawback of the current implementation is that it would put a tweet in Bulgarian on top even if it doesn't have any RT&favs. Thus all of the tweets in the current check would be ignored, even if they have a high popularity. This will be improved on in the future.
Current implementation: https://github.com/yurukov/GovAlert-framework/blob/master/streams/retweet/tasks.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment