Commit 41699493 authored by Danielvdh03's avatar Danielvdh03
Browse files

Final revision to client.py. Changed tweet filtering to only filter by State...

Final revision to client.py. Changed tweet filtering to only filter by State since not enough tweets in each county
parent c76a6258
......@@ -299,26 +299,24 @@ class Database:
state = input("Enter the name of the state : ")
state = state.strip()
region = input("Enter the county you wish to query by : ")
region = region.strip()
likes = input("Input the minimum amount of likes to query by : ")
likes = likes.strip()
query = "select display_name, tweet, likes from user inner join tweet on tweet.user_id=user.id where likes >= {0} and hashtag = \"{1}\"" \
" and county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\")) ;" .format(likes, candidate_name, region, state )
" and county_id in (select id from county where state_id = (select id from state where name = \"{2}\")) order by likes desc;" .format(likes, candidate_name, state)
# print(query)
# print(query)
results = self.execute_query(query, False)
if len(results) == 0:
print("No results were returned for county {0} in the state of {1}".format(region, state))
print("No results were returned for the state of {0}".format(state))
return
print("Results for the county {0} in the state of {1}".format(region, state))
print("Results for the state of {0}".format(state))
for result in results:
print("Username : {0}, Tweet : {1}, Likes : {2} ".format(result[0], result[1], result[2]))
print("Username : {0:20} Tweet : {1:100} Likes : {2} ".format(result[0], result[1], result[2]))
return
# count_tweet_region command : Gets number of counts by region that is within a time period and exceeds the
......@@ -331,8 +329,7 @@ class Database:
state = input("Enter the name of the state : ")
state = state.strip()
region = input("Enter the county you wish to query by : ")
region = region.strip()
likes = input("Input the minimum amount of likes to query by : ")
likes = likes.strip()
......@@ -345,17 +342,17 @@ class Database:
query = "select count(tweet) from tweet inner join user on tweet.user_id=user.id where likes >= {0} and hashtag = \"{1}\"" \
" and county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\")) ;".format(likes, candidate_name, region, state )
" and county_id in (select id from county where state_id = (select id from state where name = \"{2}\")) order by likes desc;".format(likes, candidate_name, state )
# print(query)
# print(query)
results = self.execute_query(query, False)
if len(results) == 0:
print("No tweets in county {0} above {1} likes in this timeframe".format(region, likes))
print("No tweets in state {0} above {1} likes in this timeframe".format(state, likes))
return
for row in results:
print("Number of tweets in county {0} above {1} likes within timeframe is {2}".format(region, likes, row[0]))
print("Number of tweets in state {0} above {1} likes within timeframe is {2}".format(state, likes, row[0]))
return
# update_poll_count command, updates party vote tally in a specific county
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment