Skip to content

Commit

Permalink
Check environment and step sending mail every time it runs
Browse files Browse the repository at this point in the history
When in dev and test, we limit the max number of requests to 10.
Removed the mails being sent at the end of this script, since the
volume was too high and was therefore missing the point.  We will opt
for one summary mail at the end of the day.
  • Loading branch information
GretelDePaepe committed Sep 1, 2017
1 parent 3522023 commit eaf9e06
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@

bookmark_four.p

*.p

*.csv
34 changes: 19 additions & 15 deletions FourSquareToMongo.py
Expand Up @@ -100,7 +100,7 @@ def store_four_reviews_in_mongo(db, collection, reviews, tc, venue_id):


def main():
start = dt.datetime.now()

number_of_requests = 0
"""
After validating your account with Foursquare the max number of requests
Expand All @@ -109,7 +109,13 @@ def main():
run every 2 hours (buffer). I am setting the max to 4,000 since I like to
have some buffer in case I need to test something.
"""
max_number_of_requests = 4000

environment = dl.dev_test_prod()
if environment == 'prod':
max_number_of_requests = 4000
else:
max_number_of_requests = 10
print "Only testing"
path = dl.get_path('FourSquare')

bookmark_pickle_file = "bookmark_four.p"
Expand Down Expand Up @@ -162,21 +168,19 @@ def main():

pickle.dump(bookmark, open(path + bookmark_pickle_file, "wb"))

dc_file = 'FourCountPerDay.csv'
four_places_count = dl.create_daily_count(db,
'SeattleFour',
tc,
path + dc_file)
four_reviews_count = dl.create_daily_count(db,
'SeattleFourReviews',
tc,
path + dc_file)
end = dt.datetime.now()

dl.send_mail('FourSquareToMongo', four_places_count, start, end)
dl.send_mail('FourSquareReviewsToMongo', four_reviews_count, start, end)
dc_places_file = 'FourCountPerDay.csv'
dc_reviews_file = 'FourReviewsCountPerDay.csv'
dl.create_daily_count(db,
'SeattleFour',
tc,
path + dc_places_file)
dl.create_daily_count(db,
'SeattleFourReviews',
tc,
path + dc_reviews_file)

# %% Standard boilerplate to call the main() function


if __name__ == "__main__":
main()

0 comments on commit eaf9e06

Please sign in to comment.