diff --git a/WEB/controllers/tweets.py b/WEB/controllers/tweets.py index ae17145..e6e2ba8 100644 --- a/WEB/controllers/tweets.py +++ b/WEB/controllers/tweets.py @@ -30,7 +30,7 @@ def load_tweets(): return json.dumps({'Exception': str(ex)}), 500, JSON_CONTENT_TYPE @app.route('/tweets', methods=['POST']) - def getTweets(): + def searchTweets(): ''' Retrieve tweets from the database based on provided search criteria. --- @@ -58,3 +58,20 @@ def getTweets(): search_text = body.get('search') tweets = tweets_service.get_tweets_from_db(search_text) return tweets, 200, JSON_CONTENT_TYPE + + @app.route('/tweets', methods=['GET']) + def getTweets(): + ''' + Retrieve all tweets from the database. Largely for testing purposes. + --- + produces: + application/json + responses: + 200: + description: Successfully retrieved the tweets + examples: + application/json: {"statuses": [{"created_at": "Sun Mar 31 18:32:35 +0000 2019","id": 1112422454528524300...example tweet elided}]} + 500: + description: Server error occurred + ''' + return tweets_service.get_tweets_from_db(), 200, JSON_CONTENT_TYPE diff --git a/WEB/services/tweets_service.py b/WEB/services/tweets_service.py index 365ff8f..06551a1 100644 --- a/WEB/services/tweets_service.py +++ b/WEB/services/tweets_service.py @@ -18,7 +18,7 @@ def get_tweets_from_twitter(): tweets_response = requests.get('https://api.twitter.com/1.1/search/tweets.json', params=tweet_search_params, headers=tweet_headers) return tweets_response.json() -def get_tweets_from_db(search_text): +def get_tweets_from_db(search_text = None): mongo = database_service.get_mongo_client() matching_tweets = mongo.db.tweets.find(format_db_search(search_text)) return dumps(list(matching_tweets))