Application description¶
SDD Specification¶
There are two stories to implement: As a user I want to see followers of my followers on a page. Steps:
- I go to “/” page
- I see “Connect Twitter account” button
- I press “Connect Twitter account” button
- I see Twitter popup, I follow oAuth flow authorizing app
- I get redirected to “/followers/followers” page
- I see a list of my “2nd line” followers. Each contains
- A Twitter handle, like “@madonna”
- A number of my followers, that this person follows (example, Bob and Rick follow me, Andrew follows both of them, the number is 2).
- The list doesn’t contain my direct (1st line) followers
As a technical user I want to see followers of my followers as a JSON response Starting from where last scenario ended 1. I see a URL to JSON endpoint, that displays the list. 2. I go to the URL (no auth or session required) 3. I see a JSON response, which contains a list of my “2nd line” followers. Each contains:
- A Twitter handle, like “@madonna”
- A number of my followers, that this person follows
App should be: Heroku-deployable (please provide a link to the working deployment in the README) At least slightly documented Version controlled
:: 1. GET verify_cred (me) 2. count_#_followers 3. if lower than 5000: GET list followers ids named list_of_ids
- Estimate number of gets/time (round up)
- while number of gets:
- 4.1. if number of gets less than 15:
- 4.1.1. GET list of followers ids from coursor page 4.1.2. update coursor 4.1.3. return to point 4.1.1
- 4.2. if number of gets more than 15 (long data aquisition):
- 4.2.1. get list of followers ids from coursor page 4.2.2. update coursor 4.2.3. sleep 1 min 4.2.4. return to point 4.2.1
- for item in
{4: {1: [89,4], 2: [454]}, 6768787: {1: [, 6, 7]}
There are two stories to implement: As a user I want to see followers of my followers on a page. Steps: 1. I go to “/” page 2. I see “Connect Twitter account” button 3. I press “Connect Twitter account” button 4. I see Twitter popup, I follow oAuth flow authorizing app 5. I get redirected to “/followers/followers” page 6. I see a list of my “2nd line” followers. Each contains
- A Twitter handle, like “@madonna”
- A number of my followers, that this person follows (example, Bob and Rick follow me, Andrew follows both of them, the number is 2).
The list doesn’t contain my direct (1st line) followers
As a technical user I want to see followers of my followers as a JSON response Starting from where last scenario ended
- I see a URL to JSON endpoint, that displays the list.
- I go to the URL (no auth or session required)
- I see a JSON response, which contains a list of my “2nd line” followers. Each contains:
- A Twitter handle, like “@madonna”
- A number of my followers, that this person follows
App should be: Heroku-deployable (please provide a link to the working deployment in the README) At least slightly documented Version controlled
One thing you might find troublesome is Twitter limiting API requests rate. This is part of the task, to decide what to do in such situation. Feel free to think through different solutions, but pick and implement only one (we will discuss them though).
Database¶
Data are stored in sqlite file.
- def _print_report(user_obj, followers_list):
print(“Name: {}”.format(user_obj.name)) print(“Screen Name: {}”.format(“”.join([“@”, user_obj.screen_name]))) print(“Created at: {}”.format(user_obj.created_at.isoformat())) print() print(“Followers:”) print(“-“*60) print(“{:20}{:20}{:>20}”.format(“id”, “@handle”, “# of followers”)) print(“-“*60) for follower in followers_list:
- print(“{:20}{:20}{:20}”.format(follower.id_str, “”.join([“@”, follower.screen_name]),
- follower.followers_count))
print(“-“*60) print(“nn”)